Transcluding the source of an Image out of a a field.

182 views
Skip to first unread message

Jan

unread,
Jun 28, 2016, 7:03:08 AM6/28/16
to tiddlyWiki
Hallo!
I want to build a template in which I transclude the imagelinks stored
in the field poster into an expression that renders the image.
It hast to be just the paths because I also have to use them in the
videotag.
How do you do this?
[img[{{!!poster}}]] [img{!!poster}]?

Thanks and cheers
Jan

Mark S.

unread,
Jun 28, 2016, 10:18:56 AM6/28/16
to TiddlyWiki
I don't understand what you mean by "it has to be just the paths".

The following will show an image stored in a poster field.

\define imgposter(img) [img[$img$]]
POSTER
: <$macrocall $name=imgposter img={{!!poster}}/>


Transclusion's are not real "Things", or at least that's not how they seem to work to me. They're kind of like asking the waiter to bring you a piece of toast, and instead he brings you a picture of a piece of toast. So, you can't really pass the result of transclusion, but instead you pass instructions for making the transclusion into an entity (a macro) that can combine the transclusion instructions with other instructions.

The two ways that I know of to accomplish this is by using a set widget to set an environment variable, or by using the macro call widget  to set a  macro variable.

Basically, whenever you find that you want to "pass" the results of a  transclusion to something else (like an image clause), you almost always need a macro, where the results are passed as the argument in a macro call widget, or first set as an environmental variable using Set widget.

I may not be understanding this properly, and would be open to a clearer explanations and/or techniques for dealing with problems like you've outlined here.

Good luck!
- Mark

Jan

unread,
Jun 28, 2016, 9:09:16 PM6/28/16
to tiddl...@googlegroups.com
Hi Mark,
Thanks a lot, this was it. With your hint i made a version that can be called by <<poster>> if tagged as a macro.

\define imgposter(img) [img[$img$]]
\define poster() <$macrocall $name=imgposter img={{!!poster}}/>

Now it would be perfect to be able to set an Imagewidth within this shorthand like <<poster(20px)>>

My cryptic statement meant that I can't write the code into the field (like: poster:[img[path]) into the field but just path because it has to fit into the html videotag

Thanks and Cheers Jan



Am 28.06.2016 um 16:18 schrieb 'Mark S.' via TiddlyWiki:
I don't understand what you mean by "it has to be just the paths".

The following will show an image stored in a poster field.

--
You received this message because you are subscribed to the Google Groups "TiddlyWiki" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tiddlywiki+...@googlegroups.com.
To post to this group, send email to tiddl...@googlegroups.com.
Visit this group at https://groups.google.com/group/tiddlywiki.
To view this discussion on the web visit https://groups.google.com/d/msgid/tiddlywiki/35578636-c5e3-48ba-b12b-bfb947c1efe3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mark S.

unread,
Jun 28, 2016, 11:42:13 PM6/28/16
to TiddlyWiki
Not sure if this is what you mean, since you started out by describing the situation for a template. But you can add a width parameter to the macros:

\define imgposter(img wid) [img width="$wid$" [$img$]]
\define poster(wd) <$macrocall $name=imgposter img={{!!poster}} wid=$wd$/>

which can be invoked as

<<poster 20px>>

Jan

unread,
Jun 29, 2016, 5:28:44 AM6/29/16
to tiddl...@googlegroups.com
Hi Mark,
so cool!

Thanks a lot.
Jan
Reply all
Reply to author
Forward
0 new messages