Repeated externalizing images

53 views
Skip to first unread message

Ed Heil

unread,
May 27, 2020, 11:46:20 PM5/27/20
to TiddlyWiki
I just ran across a painful "gotcha."

I have a tiddlywiki with some external images, created by running a command like this -- https://tiddlywiki.com/static/ExternalImages.html

I added a few more images by dragging and dropping, and then decided I wanted to externalize them again.  So I ran the script again.  Copied the contents of output/images to my existing images/ directory, and thought I was good.

Unfortunately all of my existing externalized images just got destroyed  -- replaced by zero-length files.

When you run that image-externalizer command, it tries to make external copies *even of the images that are already external*.  Those tiddlers have no content, so files are created with the name of the image, and filled with that "nothing".  When I copied them back out of the output directory to the image directory, the empty files overwrote the regular ones.

Luckily I had backups!  But yikes.  Externalizing already-externalized images is bad news!

This seems to do the job right:

tiddlywiki --load $tiddlyfile --savetiddlers '[is[image]!has[_canonical_uri]]' images --setfield '[is[image]!has[_canonical_uri]]' _canonical_uri $:/core/templates/canonical-uri-external-image text/plain --setfield '[is[image]!has[_canonical_uri]]' text "" text/plain --rendertiddler $:/core/save/all $tiddlyfile text/plain



Reply all
Reply to author
Forward
0 new messages