Jon.G.Bartlett@gsk.com wrote:
All,
I'm running a private Mediawiki within the company - and I want to embed objects other than the standard picture MIME formats. Obviously, clients need to have the software installed - and I know how to allow certain upload file types - but how do I enable the client to display the embedded object ?
This seems like it should be an FAQ - but I can't find any other info. Jon. PS the file type I'm particularly interested in is ISIS sketch - which is a molecular drawing program (and is different to Moelcule e.g. jMOL).
If no-one has written a plugin for that file type already, you'll have to do one yourself. Basically it's a media type handler, so say if the type is application/x-isis, you'd have:
$wgMediaHandlers['application/x-isis'] = 'IsisHandler';
class IsisHandler extends MediaHandler { function doTransform( $image, $dstPath, $dstUrl, $params, $flags = 0 ) { return new IsisPluginOutput( $image->getURL() ); }
...a few other functions to define here but all pretty easy... }
class IsisPluginOutput extends MediaTransformOutput { function __construct( $url ) { $this->url = $url; }
function toHtml( $options = array() ) { return Xml::element( 'object', array( 'src' => $this->url, ... object attributes per ISIS documentation ... ) ); } }
Put that in a file, fill in the blanks, and share it as an extension on www.mediawiki.org.
Unfortunately it's necessary at the current time to do one of these for each object type you want to embed. If you have a media handler like this, then the plugin will be invoked on the file description page, and for file links in wiki pages like [[File:Foo.mol]].
-- Tim Starling