Transcluding Base64 Image as Tiddler Background

63 views
Skip to first unread message

Scott Simmons (Secret-HQ)

unread,
Apr 26, 2021, 9:36:29 AM4/26/21
to TiddlyWiki
Hi, all —

In my ongoing quest for translucent tiddlers, I've started using images of varying color and opacity as the background for my tiddlers.

However, it occurs to me that, instead of pointing to these images elsewhere, I could embed them in my TWs and reference them without having another resource to keep track of.

My current stylesheets look something like this:

.tc-story-river .tc-tiddler-view-frame {
  background:url('images/backgrounds/92-percent-opacity-white.png') !important;
}

But if I move that PNG into a tiddler ($:/backgrounds/92%white.png), can I transclude it into my stylesheet?

I'm including transcludeinline among my stylesheet tiddler's pragma:

\rules only filteredtranscludeinline transcludeinline macrodef macrocallinline html

but I'm not pulling in the content (the image) from the tiddler.
Message has been deleted

Scott Simmons (Secret-HQ)

unread,
Apr 26, 2021, 10:07:18 AM4/26/21
to TiddlyWiki
A-ha!  It occurred to me that the core must be doing this somehow with background images, so I went looking and found TiddlyWiki's native <<datauri>> macro.

This is how to do what I was trying to do:

.tc-story-river .tc-tiddler-view-frame {
  background:url('<<datauri "$:/backgrounds/92%white.png">>') !important;
}

Some days it seems there's nothing Jeremy and the TiddlyWiki community haven't thought of.

edited and reposted to remove typo

Joshua Fontany

unread,
Apr 27, 2021, 10:59:38 PM4/27/21
to TiddlyWiki
One thing to note: When using WikiText within CSS tiddlers (tiddlers tagged `$:/tags/Stylesheet`), you do NOT want to set the tiddler-type to `text/css`. This would disable parsing of the wikitext. Leave it blank or set it to `text/vnd.tiddlywiki5`.

Best,
Joshua F
Reply all
Reply to author
Forward
0 new messages