[pmwiki-devel] Thinking about attachments

Petko Yotov 5ko at 5ko.fr
Wed Apr 15 23:56:05 PDT 2026


The PmWiki image way of doing these may work and feel intuitive.

If the url is in double brackets, it is a link:
   [[Attach:image.jpg]]
   [[https://server/image.jpg]]

For "bare urls", the picture is embedded with an <img> tag:
   Attach:image.jpg
   https://server/image.jpg

Something like this only reacts to bare urls ending in gpx|kml:


   Markup('gpx','<urllink',
     "/\\b(?>(\\L))([^\\s$UrlExcludeChars]+\\.(?:gpx|kml))/",
     "MyTraceLink");

   function MyTraceLink($m) {
     extract($GLOBALS["MarkupToHTML"]);
     global $LinkFunctions;
     $link = $LinkFunctions[$m[1]]($pagename,$m[1],$m[2],@$m[4],'trace');
     return Keep("<span class='map'>$link</span>",'L');
   }

Then your function outputs <span class="map"> that is detected by Ape.

I plan to do this for video and audio files, but maybe with a switch so 
that existing bare links don't suddenly become embedded media.

Petko

-- 
If you upgrade :  https://www.pmwiki.org/Upgrades

On 15/04/2026 06:17, Simon wrote:
> I'm thinking about a couple of PmWiki features related to files and
> attachments.
> 
> When a file is "Attach:"ed to pm Wiki there are two of what I think of
> as "handlers".
> If the file has an image extension, a 'handler' generates image markup
> to display the file as an image.
> For all other file extensions a default 'handler' generates markup to
> allow the file to be downloaded.
> 
> The question is, is it possible to add a handler for a set of file
> extensions that generates markup specifc to those file extensions?
> 
> PmWiki supplies basics for managing attachments (or files) (e.g. a
> built in (:attachlist [1]:), (:if attachments [2]...:)).
> 
> Pagelists [3] does not recognise attachments, however for images the
> awesome (to me) recipe Thumblist [4], and a few other recipes, allow
> selection and enumeration of image files and their display.
> There is a good recipe, Attachtable [5], to manage, select and
> enumerate attachments.
> 
> Let's say I am looking at a new class of files, say with the
> extensions .gpx or .kml.
> Instead of displaying as a download link I'd like them to say use the
> %map% markup from the ape [5] recipe.
> Also, I'd like some ability to select, sort, and enumerate them, not
> dissimilar to the way thumblist works for images.
> 
> Before I develop anything I'm keen to hear how you think this could
> fit into the existing PmWiki framework?



More information about the pmwiki-devel mailing list