I am building an advanced image handler for Joomla 3x where images are built dynamically at run-time based on a number of parameters defined in tags inserted into articles. An example look like this:
{imgh}>>JSON code<<{/imgh}
where >>JSON code<< code could be as simple as this:
{"cmd": "get_image", "id": 306, "w": 600}
The JSON code translates into: "Fetch image with ID = 306, scale it to a width of 600 pixels (using Imagick) and return the <IMG...> tag to me complete with ALT text (fetched from database), download links, upscale links using modals etc.
I have managed to make it work (example at https://cnj.dk/gliding/jorn-rehne-andersen-fotoalbum-1982) but there is an efficiency problem with long articles containing many {imgh} tags. It turns out that even though a large article is broken into smaller pieces using "system-pagebreak" (the "insert Page Break" button in the editor), my "content" plugin will still be presented with the full article at every page display. Thus it will run the interpreter code on each and every {imgh} tag found in the entire article, even though it is only supposed to present a tiny fraction of it. From my plugin I could decide to count the appearances of the '<hr class="system-pagebreak" title="XXXX" />' and only work on the relevant ones but how can my plugin determine which page it is on?
Due to this problem the site linked above does not use "system-pagebreak" but I manually split it into sub-articles. That is not optimal though.
onContentPrepare
)?