Extension talk:LinkifySVG

From Organic Design wiki
Revision as of 05:32, 27 February 2009 by Nad (talk | contribs) (Intercepting uploaded SVG's)

Purpose

This extension is planned to intercept uploading of SVG files and convert any text in them into links if they contain a valid URL or are surrounded by double square brackets to indicate a wiki article.

Linkifying an SVG

First the xlink namespace must be added to the SVG opening element:

xmlns:xlink="http://www.w3.org/1999/xlink"

Next the XML must be parsed and any text elements with matching content converted by surrounding it with an a element. Here's an example of a text element from an SVG created with Inkscape which has been simplified a bit for clarity and linkified.

{{{1}}}

Intercepting uploaded SVG's

The UploadVerification hook has been around since MW1.6 and allows an uploaded file to be modified before being saved, it is called with three parameters, saveName, tempName, and error passed by reference. It's still possible for the upload to fail before being saved though, so it may be better to adjust the file after the upload is complete using the UploadComplete hook instead which is called with the image object reference.