[tw5] transcluding icon field

Hi, I’m trying to use images referenced in the icon field within the body of a tiddler.

I realise that I can transclude the image eg. <$transclude tiddler={{!!icon}}/> but cannot control size or other attributes. So have tried to use “img” with a few syntax variations eg. None work.

[img [{{!icon}}]]
[img [tiddler={{!icon}}]]

help (code and/or understanding) would be gratefully received, kindest regards

I’ve posted this elsewhere but forgot to mention that i’m using TW 5.1.24-prerelease on windows11 (Firefox). Thanks!

Using the “modern” $transclude widget parameters available in TW5.3.0 and above (released 01-July-2023) , you can write something like this:

@@fill:blue;<$transclude $tiddler={{!!icon}} size=“10em”/>@@

Note that the $tiddler parameter has a leading $ to enable “modern” parameter handling, but the size parameter does NOT have a leading $, indicating that it is an extra parameter that will be passed to the icon tiddler for use as a variable within the SVG content definition.

You will need to upgrade from TW 5.1.24-prerelease (see https://tiddlywiki.com/upgrade) to get this new parameter handling.

Also, please note that, while this Google Group is still available, it is no longer the primary location for posting questions and discussions about TiddlyWiki and the TiddlyWiki community has moved to https://talk.tiddlywiki.org where you will find much more activity and timely responses.

enjoy,
-e

1 Like

Hi, What’s the text in the icon field?

Usually field transclusions look like this: {{!!icon}}

Links look like this: [[HelloThere]]

Image links are special links to image-tiddlers, if they exist as real tiddlers and not as a text-reference in a field.

Your idea is right, but an image-link that you created does not exist. Hence my question: How does your icon-field look like.

Thanks for both of you ytaking the time to reply - much appreciated!

Perhaps I’m not explaining very well - sorry

  • The code “icon field = {{!!icon}}” diaplys the field contents as text eg. default1.svg
  • If i transclude the icon field with “<$transclude tiddler={{!!icon}}/>” then the image “default1.svg” is displayed full size
  • If I use img eg. “img width=200 height=200 [default1.svg]]” I can control the size of the image, but I have to manually write the name of the image used

I want to make something like “[img width=200 height=200 [<$transclude tiddler={{!!icon}}/>]]” so that whatever is referenced in the icon field is displayed with defined size

whatever syntax i’'ve tried doen’t work. Have upgraded to latest TW, but not change. Presumably Eric, you’re referring to text size, not image size?

Have you tried using the $image widget, like this:

<$image source={{!!icon}} width="200" height="200"/>

-e

1 Like

Marvellous - this works beautifully - thanks very much!

1 Like