How to use transclusion with an image src

68 views
Skip to first unread message

naris

unread,
Oct 15, 2019, 11:44:36 AM10/15/19
to TiddlyWiki
I want to create a reusable header for my tiddlers that contains a changeable image. I came across transclusion, but I can't figure how to use it with images.

I have no issue displaying an image with an explicit declaration:
[img[path/to/image.png]]
<img src="path/to/image.png">

however I'm not having any luck displaying the image with transclusion. Using:
image: image.png

I get a broken image when I try to use the following:
[img[path/to/{{!!image}}]]
<img src="path/to/{{!!image}}">

Nothing displays when I use the following:
[img[path/to/<$transclude field="image"/>]]

And the following just renders it as text (<img src="path/to/image.png">):
<img src="path/to/<$transclude field="image"/>>

Is what I'm trying to do not possible, or how can I get this to work?

BurningTreeC

unread,
Oct 15, 2019, 12:13:12 PM10/15/19
to TiddlyWiki
Hi @naris


I want to create a reusable header for my tiddlers that contains a changeable image. I came across transclusion, but I can't figure how to use it with images.

I have no issue displaying an image with an explicit declaration:
[img[path/to/image.png]]
<img src="path/to/image.png">

however I'm not having any luck displaying the image with transclusion. Using:
image: image.png

I get a broken image when I try to use the following:
[img[path/to/{{!!image}}]]
<img src="path/to/{{!!image}}">


Here you could construct the path like the following:

\define construct-path()
[img[path/to/$(image)$]]
\end
<$set name="image" value={{!!image}}>
<<construct-path>>
</$set>

And for the second example

\define construct-path()
<img src="path/to/$(image)$">
\end
<$set name="image" value={{!!image}}>
<<construct-path>>
</$set>

naris

unread,
Oct 15, 2019, 2:11:54 PM10/15/19
to TiddlyWiki
Thanks, that's exactly what I needed. :)
Reply all
Reply to author
Forward
0 new messages