From 614ba8432f2ddfd7114df751b9d447d5599fcdfc Mon Sep 17 00:00:00 2001 From: Mario Pietsch Date: Mon, 17 Feb 2025 17:13:38 +0100 Subject: [PATCH] [DOCS] Improve External Images Docs (#8954) --- .../tiddlers/concepts/ExternalImages.tid | 38 ++++++++++++++----- 1 file changed, 28 insertions(+), 10 deletions(-) diff --git a/editions/tw5.com/tiddlers/concepts/ExternalImages.tid b/editions/tw5.com/tiddlers/concepts/ExternalImages.tid index 077faedef..a4aaa906a 100644 --- a/editions/tw5.com/tiddlers/concepts/ExternalImages.tid +++ b/editions/tw5.com/tiddlers/concepts/ExternalImages.tid @@ -1,5 +1,5 @@ created: 20140610213500000 -modified: 20241030132047048 +modified: 20250217154855572 tags: Concepts Features title: ExternalImages type: text/vnd.tiddlywiki @@ -23,22 +23,28 @@ To manually create an external image just create the tiddler with the appropriat The following steps are used to create a static HTML file version of a wiki accompanied by an ''images'' folder containing the referenced external images: # Create image tiddlers in your TiddlyWikiFolders in the usual way -# Save the images as separate files (by convention, in a subfolder named ''images'') +# Save the images as separate files (by convention, in a subfolder named ''/images'') # Externalise the image tiddlers by giving them a ''_canonical_uri'' field # Save the main HTML file Note the image files must be saved before they are externalised. Externalising them destroys the ''text'' field within the in-memory copy of the wiki store, meaning that attempts to save them will fail. -For an example see the ''externalimages'' build target of the demo ''tw5.com'' wiki: +!! External Image Configuration + +For an example create an ''externalimages'' build target in a ''tiddlywiki.info'' file: ``` ---save [is[image]] images ---setfield [is[image]] _canonical_uri $:/core/templates/canonical-uri-external-image text/plain ---setfield [is[image]] text "" text/plain ---render $:/core/save/all externalimages.html text/plain +"build": { + "externalimages": [ + --save [is[image]] images + --setfield [is[image]] _canonical_uri $:/core/templates/canonical-uri-external-image text/plain + --setfield [is[image]] text "" text/plain + --render $:/core/save/all externalimages.html text/plain + ] +} ``` -!! Saving Separate Image Files +!! Externalising Image Tiddlers The following `--save` command (see [[SaveCommand]]) can be used to save the images of a wiki into an ''images'' subfolder: @@ -46,8 +52,6 @@ The following `--save` command (see [[SaveCommand]]) can be used to save the ima --save [is[image]] images ``` -!! Externalising Image Tiddlers - Two `--setfield` commands are used: the first sets the ''_canonical_uri'' field to a URI derived from the title of the tiddler, and the second clears the text field. ``` @@ -65,6 +69,20 @@ The template tiddler [[$:/core/templates/canonical-uri-external-image]] contains Note that these operations modify the tiddlers in the wiki store and so may affect the operation of subsequent commands. +!! Node.js Command to Build External Images + +The following command will create external images in the `myWiki/output` folder. + +``` +tiddlywiki myWiki --build externalimages +``` + +On Windows the following command will create external images that are part of the [[tw5.com edition|https://github.com/TiddlyWiki/TiddlyWiki5/blob/master/editions/tw5.com/tiddlywiki.info#L26]]. The files will be created in the output directory. + +``` +tiddlywiki .\editions\tw5.com --build index +``` + ! Using External Images You can't edit an external image directly in the browser except by changing the URI field to point to a different image.