[TW5] Needing to combine these 2 macros

160 views
Skip to first unread message

Jon

unread,
Dec 17, 2017, 2:42:55 AM12/17/17
to tiddl...@googlegroups.com
Hi,

This macro provided by Mark S in an earlier post will give a clickable thumbnail image which will then go to full size in the browser. Inserting the macro in a tiddler and then tagging it with $:/tags/Macro will then, of course, make this a global effect for all photos in the wiki eg. <<imageit "PictureFolder/picture 1.jpg">> (the quotes around this part "$image$" now allows for a gap in the picture file name).

\define imageit(image:"image.jpg")
<a href="$image$" target="new"><img src="$image$" width="25%" height="25%" /></a>
\end

e
.g.

<<imageit "images/google_drive.png">>



I think this is brilliant, and I'm going to apply it retrospectively to all the pictures in my wiki.

Whilst I'm at it, I'd also like to incorporate a global folder path for external images.

So the question is, how do I join these two macros together?

Thanks
Jon

Mat

unread,
Dec 17, 2017, 8:00:02 AM12/17/17
to TiddlyWiki
I think this should work

\define imgpath(img) images/$img$

\define imageit(image:"image.jpg")
<$set name=path value=<<imgpath "$image$">>>
<a href="$image$" target="new"><img src=<<path>> width="25%" height="25%" /></a>
</$set>
\end



<:-)

Jon

unread,
Dec 17, 2017, 2:58:14 PM12/17/17
to TiddlyWiki
Hi Mat,

Thanks for your reply.

I don't know if this is what you intended, but I inserted your macro before the macro in the $:/macros/ximg tiddler.

I then typed <<ximg "Photo.jpg">> in a new tiddler which produced a photo from the global directory as before, but it didn't have the desired clickable action.

(<<imageit "Photo.jpg">> produced an empty thumbnail)

As you've probably gathered, I've no idea how these things go together.

Should I have done something else?


Thanks
Jon

Mark S.

unread,
Dec 17, 2017, 3:57:31 PM12/17/17
to TiddlyWiki
This should do literally what you want:

\define imageit(image:"image.jpg",path:"TW-Images/2017/")
<a href="$path$$image$" target="new"><img src="$path$$image$" width="25%" height="25%" /></a>

BTW, I have a variation of Tobias' macro that allows me to configure the image path with a drop-down selection of paths. So it's easier to hop between platforms. At least in theory.

-- Mark

Jon

unread,
Dec 17, 2017, 4:58:55 PM12/17/17
to TiddlyWiki
Hi Mark,

Do you mean using this macro alone, instead of what's gone before?

In which case I put it into a tiddler, changed your example folder path, tagged it with $:/tags/Macro and in a separate tiddler inserted <<imageit "Photoname.jpg">>

However, no luck. What I did notice though is the macro tiddler produced a thumbnail which wanted to find...ImageFolder/$path$$image$. and the other tiddler didn't show anything.

Cheers
Jon

Mat

unread,
Dec 17, 2017, 5:37:45 PM12/17/17
to TiddlyWiki
Jon, this is how you would use this. Assume you have a subfolder in your TW directory (i.e where your TW resides) called "images".

In a tiddler you write 

title: whatever you want
tags
: $:/tags/Macro
text
:

\define imgpath(img) images/$img$

\define imageit(image:"image.jpg")
<$set name=path value=<<imgpath "$image$">>>
<a href="$image$" target="new"><img src=<<path>> width="25%" height="25%" /></a>
</$set>
\end

Then in another tiddler you use it like so: 

<<imageit "myprettyimage.jpg">>


<:-)

Jon

unread,
Dec 17, 2017, 6:09:20 PM12/17/17
to TiddlyWiki
Hi Mat,

Thanks for this and the instructions.

To be on the safe side I created a subfolder called "images" and put a photo in it.

This part<<imageit "myprettyimage.jpg">> produced the thumbnail alright but when clicked, there's a "File not found" message as it's still looking in the main folder rather than the "images" subfolder.

Almost there!

Jon

Mark S.

unread,
Dec 17, 2017, 6:38:05 PM12/17/17
to TiddlyWiki
Oops, I was working on a tablet and typing in the small wedge of space it gave me. Lost the "\end". This works on my system:

\define imageit(image:"image.jpg" path:"TW-Images/2017/")

<a href="$path$$image$" target="new"><img src="$path$$image$" width="25%" height="25%" /></a>
\end

Note that the default path must have a final forward slash on the end. Yes, this is a replacement for the previous macros.

Good luck!
Mark

Mat

unread,
Dec 17, 2017, 8:53:17 PM12/17/17
to TiddlyWiki
Jon
 
This part<<imageit "myprettyimage.jpg">> produced the thumbnail alright but when clicked, there's a "File not found" message as it's still looking in the main folder rather than the "images" subfolder.

Ah, sorry, he href should also call the macro. See if doing this helps:

<a href=<<path>> target="new"> etc
 
<:-)

Jon

unread,
Dec 18, 2017, 1:58:23 AM12/18/17
to TiddlyWiki
Mat & Mark, they both worked.

That's my WikiChristmas present right there!

Cheers
Jon
Reply all
Reply to author
Forward
0 new messages