I am going through the Reading data from JSON tiddlers documentation and trying to work out how to implement it so that I can display an externally hosted image just by looking up a key/value pair in a JSON tiddler consisting of URI’s, such as…
I presume that I will need to create a macro which takes the JSON data tiddler name as one parameter, and the search key as a second parameter, and returns the found value, which can then be passed into an <$image> widget as the source attribute. Presumably I’ll also need some error handling. Does all of that sound about right? It has been a long time since I last did something like this, so I am looking for a bit of validation here, or gentle nudging towards a better solution. All I’m trying to achieve is to have a simple list of links to my externally hosted images, and then be able to display them by looking up the list as a key/value pair. I want to be able to make these images easily reusable within my wiki, while giving a single point of reference to be able to update the external URI’s whenever needed, without having to chase back to every single tiddler which uses the updated image.
I have done the same thing, but I think the loop convenience of wikitext is too cumbersome. I solved this problem using js, and it is more flexible using js.
Thanks for this @saqimtiaz. Can you remind me please, how would I would make this into a global macro / procedure so that the invocation for it can be accessed from any tiddler without having to expressly define the \procedure on every tiddler where it gets used. Also, do I need any error handling in the procedure, such as for what to do if the requested parameters do not exist?
That is perfect, I was wondering if I had to do something myself for handling this, but it looks like TW already has that built-in. Thanks again for the help with this!
After all of that effort, I have just remembered about creating External Images as tiddlers. This might be a much simpler way to achieve the same thing, but without the need for a list of external images at all! Gosh, it is going to take me a while to get back into the “TiddlyWiki-way” of doing things!