[TW5] Set img path variable ?

1,215 views
Skip to first unread message

Sylvain Naudin

unread,
Nov 12, 2014, 2:24:24 AM11/12/14
to tiddl...@googlegroups.com
Hello,

Since few weeks, I'm working on end-user documentation file using TiddlyWiki for work, because TW is wonderful for that :)

I've many images. I don't want to include all, because html weight will increase considerably. So I insert with local path, like :

[img[tooltip|folder/sub-folder/image.png]]

I wondering if we could set path folder as a variable ?

I would like to share the index.html file more easily and save images on a network directory (smb share I guess), but I also want to work on master TW locally. So I don't want to always use foreign folder storage.

If I'm not clear, or if you have better idea to deal with img, I'm listening :)

Best regards,
Sylvain

PMario

unread,
Nov 12, 2014, 5:04:51 AM11/12/14
to tiddl...@googlegroups.com
Hi Sylvian,

It's relatively simple, but needs some TW background ;)

Create a tiddler named eg: globalImageMacro and tag it with: $:/tags/Macro to make it a global macro

content:

\define imageFullPath(image, tooltip, path)
[img[$tooltip$|$path$$image$]]
\end

\define iLink( image, tooltip:"image", pathConfig:"imagePath")
<$macrocall $name="imageFullPath" path={{$pathConfig$}} image="$image$" tooltip="$tooltip$"/>
\end


Then create a tiddler named: imagePath   with your base path. eg:

for a network share:
file:\\\\\COMPUTER_NAME\Users\Mario\Pictures\2010-10\
see: 5 bachslashes !!!

same computer absolute path
file:\\Users\Mario\Pictures\2010-10\

relative path as a subdirectory to the tiddlywiki.html file.
.\images\

The "backslash" at the end is important!!

-----------

To get the image use:

<<iLink "my image with spaces.gif">>

The default tooltip is "image" if you want to change it use:

<<iLink "my image with spaces.gif" tooltip:"my tooltip">>



The default path config tiddler is: imagePath
If you want to change it use:

<<iLink "my image with spaces.gif" tooltip:"my tooltip" pathConfig:"otherImagePathTiddler">>


I did test this on my computer. So it should work :)
-mario

Message has been deleted

PMario

unread,
Nov 12, 2014, 5:21:33 AM11/12/14
to tiddl...@googlegroups.com
,,, and again :)

same computer absolute path
file:\\\c:\Users\Mario\Pictures\2010-10\

PMario

unread,
Nov 12, 2014, 4:19:25 PM11/12/14
to tiddl...@googlegroups.com
On Wednesday, November 12, 2014 4:06:54 PM UTC+1, Sylvain Naudin wrote:
(absolute path like file:\\Users\Mario\Pictures\2010-10\ doesn't work for me on Windows and Firefox).

There's a second post with a fix.
-m

Sylvain Naudin

unread,
Nov 12, 2014, 5:41:21 PM11/12/14
to tiddl...@googlegroups.com

Ah ok ! So it's fine :)
Many thanks

Tobias Beer

unread,
Nov 13, 2014, 4:07:08 AM11/13/14
to tiddl...@googlegroups.com
Hi Mario,
 
It's relatively simple, but needs some TW background ;)
... 
 

Thanks for all that, highly educational!

-tb

Tobias Beer

unread,
Nov 13, 2014, 4:08:42 AM11/13/14
to tiddl...@googlegroups.com
Btw. is there already a place where solutions / walkthroughs like these can be found in a categorized manner other than tw.com?

-tb

Sylvain Naudin

unread,
Nov 13, 2014, 10:40:33 AM11/13/14
to tiddl...@googlegroups.com


Le jeudi 13 novembre 2014 10:08:42 UTC+1, Tobias Beer a écrit :
Btw. is there already a place where solutions / walkthroughs like these can be found in a categorized manner other than tw.com?

-tb

I started it in french and try to maintain sort of that on my blog.


There are so many use of case, it's like have a gift for Christmas every day ;)

Tobias Beer

unread,
Nov 13, 2014, 1:19:07 PM11/13/14
to tiddl...@googlegroups.com
Merci Sylvain,

found some references, listing yours as well:

http://tiddlywiki.com/#Resources

...and then from there. :-)

What I meant was more of a centralized, collaborative thing to document know-how, something along the lines of tiddlywiki.org.

Best wishes, Tobias.

Ton Gerner

unread,
Nov 13, 2014, 1:54:42 PM11/13/14
to tiddl...@googlegroups.com
Hi Tobias,

Andreas Hahn started the site http://twguides.org/ (or http://tiddlywikiguides.org) see [1]
It is just a start but nothing like http://tiddlywiki.org/

For the rest you have to search ;-)
A good starting point is [2] where you will find my customization guides as well [3]

Cheers,

Ton

[1] https://groups.google.com/d/msg/tiddlywiki/xNeS-QxXvMQ/mlII13MvdbcJ
[2] http://tiddlywiki.com/#Community
[3] http://tongerner.tiddlyspot.com/

Mat

unread,
Nov 13, 2014, 1:55:33 PM11/13/14
to tiddl...@googlegroups.com
Tobias Beer wrote:
What I meant was more of a centralized, collaborative thing to document know-how, something along the lines of tiddlywiki.org.

Nope. And you know what I'm thinking ;-)
 

Tobias Beer

unread,
Nov 13, 2014, 2:56:48 PM11/13/14
to tiddl...@googlegroups.com
Thanks Ton, much appreciated.

Tobias Beer

unread,
Nov 16, 2014, 9:53:07 AM11/16/14
to tiddl...@googlegroups.com
Hi PMario,

I took the liberty to put your solution up for demonstration and as a reference:

I changed some of the naming.
Hope that's ok with you.

Best wishes, Tobias.

PMario

unread,
Nov 16, 2014, 2:19:07 PM11/16/14
to tiddl...@googlegroups.com
On Sunday, November 16, 2014 3:53:07 PM UTC+1, Tobias Beer wrote:
I changed some of the naming.
Hope that's ok with you.

sure :)
-m

Sylvain Naudin

unread,
Nov 25, 2014, 5:11:33 AM11/25/14
to tiddl...@googlegroups.com
Hi Mario,

Do you know how I could define a widht parameter inside macro ? (and if we can ^^')

for exemple width=256

Thanks,
Sylvain

Sylvain Naudin

unread,
Nov 25, 2014, 5:18:49 AM11/25/14
to tiddl...@googlegroups.com
I guess something like this : [img $width$[$tooltip$|$path$$image$]] and define in macrocall the variable..

Tobias Beer

unread,
Nov 25, 2014, 6:07:00 AM11/25/14
to tiddl...@googlegroups.com
Do you know how I could define a widht parameter inside macro ? (and if we can ^^')

for exemple width=256

The ximg macro now also allows you to specify a width...


Best wishes, Tobias.

Tobias Beer

unread,
Nov 25, 2014, 6:10:22 AM11/25/14
to tiddl...@googlegroups.com
Do you know how I could define a widht parameter inside macro ?  
 
I guess something like this : [img $width$[$tooltip$|$path$$image$]] and define in macrocall the variable..

[img width="$width$" class="$class$" [$tooltip$|$path$$image$]]

Best wishes, Tobias.

Sylvain Naudin

unread,
Nov 25, 2014, 8:01:53 AM11/25/14
to tiddl...@googlegroups.com


Le mardi 25 novembre 2014 12:10:22 UTC+1, Tobias Beer a écrit :

[img width="$width$" class="$class$" [$tooltip$|$path$$image$]]


Exactly, thanks Tobias :)

Since I already use Mario code from my first question, I've modify to that :

\define imageFullPath(image, tooltip, path, width, class)

[img width="$width$" class="$class$" [$tooltip$|$path$$image$]]
\end


\define iLink( image, tooltip:"image", pathConfig:"imagePath", width, class)
<$macrocall $name="imageFullPath" path={{$pathConfig$}} image="$image$" tooltip="$tooltip$" class="$class$" width="$width$"/>
\end


Best wishes,
Sylvain

PMario

unread,
Nov 25, 2014, 2:49:36 PM11/25/14
to tiddl...@googlegroups.com
Nice, that it works :)
-m

Sylvain Naudin

unread,
Nov 12, 2014, 10:06:54 AM11/12/14
to tiddl...@googlegroups.com
Thank you Mario for your quick reply !! That exactly what I want :)

Now I can just edit my imagePath tiddler to switch my work environment.

I also try with an URL (if I store images on a webserver) and it's OK.

(absolute path like file:\\Users\Mario\Pictures\2010-10\ doesn't work for me on Windows and Firefox).


Thanks you again,
Sylvain
Reply all
Reply to author
Forward
0 new messages