Surge
September 3, 2024, 5:05pm
1
Hello, I was wondering why this is not working:
<$list filter="[!is[system]type[image/png]sort[created!]]" variable=mine>
[img[<<mine>>]]
<br>
</$list>
I want to basically loop through the image tiddlers and display them as links. Why doesn’t <<mine>> get expanded inside the img tag?
Can you direct me to the place in the documentation?
Thank you!
[Edited] To wrap <<mine>> in single back ticks to register as code.
[img[...]] is a “shortcut” syntax for the <$image ...> widget.
As a general rule, wikitext shortcut syntax does not support references to variables and can only be used with literal parameter values.
To do what you want, you should use:
<$image source=<<mine>>/>
-e
Surge
September 3, 2024, 5:45pm
3
Ah, right, I seem to recall that now. Is there in the docs I can read about those shortcuts, variable interpolation, etc?
Thank you, Eric!
Surge
September 3, 2024, 5:48pm
4
Oh, also is there a way to make the images clickable so they take me to the tiddler?
Enclose the $image widget within a $link widget, like this:
<$list filter="[!is[system]type[image/png]!sort[created]]" variable=mine>
<$link to=<<mine>>><$image source=<<mine>>/></$link><br/>
</$list>
Note also that, if you omit the variable=mine syntax, the $list widget will automatically use a variable named currentTiddler… and many widgets that expect a tiddler name as a parameter value (e.g., the to=... parameter in the $link widget) will default to using currentTiddler as well.
Thus, the above wikitext code could be written more compactly as:
<$list filter="[!is[system]type[image/png]!sort[created]]">
<$link><$image source=<<currentTiddler>>/></$link><br/>
</$list>
enjoy,
-e
edited to fix error copied from OP:
changed sort[created!] to !sort[created]
(thanks go to @CodaCoder for noticing this!)
Surge
September 3, 2024, 7:01pm
6
Awesome, thank you. Last question, I noticed that the image picker shows the images not in the chronological order. Is there a way to change that?
The TWCore <<image-picker>> macro supports an optional subfilter parameter.
To show the images, newest first, try using:
subfilter="!sort[modified]"
See image-picker Macro for documentation.
-e
Surge
September 3, 2024, 8:06pm
8
cool, for this type[image/png] is there a better way to describe all possible images (png, gif, etc)?
Perhaps try the is[image] filter operator.
See is Operator and ContentType for more details.
Just for the sake of newbies reading this thread…
Unless you have a field called created!