Help needed to debug a filter run

<$let
    myCur=<<currentTiddler>>
    sp=""" """
    img1="\[img\["
    img2=".png\]\]"
    img3=".jpg\]\]"
    imgs={{{ [<myCur>get[text]search-replace:gi:regexp[\n],<sp>search-replace:gi:regexp<delink>,[]search-replace:gi:regexp<img1>,[@1@@]split[@1]prefix[@@]search-replace:gi:regexp<img2>,[.png@@]split[@@]regexp[(\.png$)]format:titlelist[]join[ ]] ~[<myCur>transcludes[]suffix[.png]format:titlelist[]join[ ]] }}}
   delink="\[\[.*?\]\]"
>
<$list filter="[enlist<imgs>]" variable="img">

I have images in my tiddlers in two formats

  1. [img[image-name]]
  2. {{image-tiddler-name.png}}

Some tiddlers have transcluded images, while some tiddlers have images in [img[]] format. I want to list all the images of both these formats and display them using a viewtemplate. But the above code is not listing the transcluded images.

    imgs={{{ [<myCur>get[text]search-replace:gi:regexp[\n],<sp>search-replace:gi:regexp<delink>,[]search-replace:gi:regexp<img1>,[@1@@]split[@1]prefix[@@]search-replace:gi:regexp<img2>,[.png@@]split[@@]regexp[(\.png$)]format:titlelist[]join[ ]] ~[<myCur>transcludes[]suffix[.png]format:titlelist[]join[ ]] }}}

This part of the code may not be correct. Can someone help ?

You need to define delink before imgs for it to be available as a variable.

1 Like

I see 2 problems in your code:

  1. You use delink before defining it. You should move it up in the $let widget
  2. Your last filter run is an “else” filter run, so it won’t be evaluated unless other filter runs return no result. Remove the ~ at the start of the filter run.

Hope this helps

Fred

1 Like

I think the culprit was the ~ . Its working once I removed the ~

@etardiff @tw-FRed

I also needed to modify the code like this to make it work.

    imgs={{{ [<currentTiddler>get[text]search-replace:gi:regexp[\n],<sp>search-replace:gi:regexp<delink>,[]search-replace:gi:regexp<img1>,[@1@@]split[@1]prefix[@@]search-replace:gi:regexp<img2>,[.png@@]split[@@]regexp[(\.png$)]] [<currentTiddler>transcludes[]suffix[.png]] :and[format:titlelist[]join[ ]] }}}

But still the transcluded images are not being shown in the macy widget of macy plug in (which was the reason for creating this filter run). I have set up a demo here. Can you help me to find why its not working ?

I was having trouble following your filter, so I took the liberty of starting fresh. Try this out:

<$macy columns="6" breakAt="1300:5:15:15 940:3:10:10 520:2:5:5 400:1:1:1">
<$let
	imgfile="\.(jpg|png|gif)$"
	rb="]]"
	img="[img["
	imgs={{{ [<currentTiddler>] [<currentTiddler>transcludes[]]
		+[get[text]split<rb>] :map[split<img>last[]]
		+[regexp<imgfile>format:titlelist[]join[ ]] }}}
>
<$list filter="[enlist<imgs>]" variable="img">
<$button class="tc-btn-invisible item-container" tag="div" actions="""
<$action-spotlight
	$images=<<imgs>>
	$start=<<img>>
/>""">
<$image source=<<img>> class="item" />
</$button>
</$list>
</$let>
</$macy>

The “image” tiddler you were transcluding also uses the [img[...]] format, so it’s not enough to to simply use <currentTiddler>transcludes[] — this will return the title of the transcluded tiddler, not its text content. Instead, you’ll need to get the text of each transcluded tiddler as well as the <<currentTiddler>>, then apply the same split/regexp processing to extract any relevant image links.

1 Like

This one works…thank you so much for the help.
Any idea why the images are vertically aligned instead of horizontal alignment?

Oops, that’s because I forgot to take out the extra line break after the $let widget. I’ll edit my code above.