Syntax for: "background-image: url( my local img tiddler );"

181 views
Skip to first unread message

Mat

unread,
Aug 28, 2015, 5:01:25 PM8/28/15
to TiddlyWiki
Using the tc-tagged-<tagname> technique you can style tiddlers individually.

But how do I set an image that I have as a tiddler, e.g Motovun Jack.svg, to be the background in some other tiddler?

The doc link above gives example:

background-image: url(./tardis_back.svg);

but this path is not relevant in this case and merely writing the name of the image tiddler does not work.

Assuming image tiddlers that are local (and work, i.e you do see the image), is there a difference in the above syntax depending on file types (png, svg...)

<:-)

 

Birthe C

unread,
Aug 28, 2015, 5:49:58 PM8/28/15
to TiddlyWiki
Hi Mat,

\define datauri(title)
<$macrocall $name="makedatauri" type={{$title$!!type}} text={{$title$}}/>
\end

div
.tc-tagged-cat{
background
: url(<<datauri "Motovun Jack.svg">>);
}


Birthe

Eric Shulman

unread,
Aug 28, 2015, 5:50:14 PM8/28/15
to TiddlyWiki
On Friday, August 28, 2015 at 2:01:25 PM UTC-7, Mat wrote:
Using the tc-tagged-<tagname> technique you can style tiddlers individually.
But how do I set an image that I have as a tiddler, e.g Motovun Jack.svg, to be the background in some other tiddler?
The doc link above gives example:
background-image: url(./tardis_back.svg);
but this path is not relevant in this case and merely writing the name of the image tiddler does not work.


To use the content of an image tiddler in your CSS, you need two things:

1) The 'type' field of the stylesheet tiddler should be blank (or set to "TiddlyWiki 5").  This allows the content to be "wikified", so that embedded macros can be processed
2) Use the <<datauri>> macro to fetch the image tiddler content and format it as a base64-encoded URI that can be embedded in the CSS, like this:
background-image: url(<<datauri "Motovun Jack.svg">>);


enjoy,
-e

Mat

unread,
Aug 29, 2015, 6:28:40 AM8/29/15
to TiddlyWiki
Great help from two directions simultaneously - thank you! :-)

More to come on the matter...

<:-)
Reply all
Reply to author
Forward
0 new messages