Extension talk:Inline SVG

From MediaWiki.org
Jump to navigation Jump to search

Making it appear in Special:Version[edit]

Add this to the code:

// Extension credits that show up on Special:Version
$wgExtensionCredits['parserhook'][] = array(
	'name' => 'Inline_SVG',
	'author' => 'Assela Pathirana',
	'url' => 'http://www.mediawiki.org/wiki/Extension:Inline_SVG',
	'description' => 'Allows the display of SVG files.'

--Michael Alabastro

Problem with links[edit]

I have the inline SVG working well, but am having problems with the links. I am trying to create an image map type diagram which will link to other wiki pages.

But all the links (absolute) open up in the svgcode window. Is there anyway I can get them to open in the full window.

Many thanks

--Markemark2 08:34, 23 November 2007 (UTC)Mark

Fixed, I just needed to add target=_parent to my SVG code. --Mark 08:43, 23 November 2007 (UTC)

Transform into PNG[edit]

The Browsers do not accept SVG, so I would like to transform the SVG image into a PNG image and display the PNG-File.

I tried it by changing the sourcecode of Extension inline svg in the following way


  $image = UnregisteredLocalFile::newFromPath($pname,'image/svg');
  $handler = MediaHandler::getHandler('image/svg');

  $handler->normaliseParams(  $image ,$params );
  $thumb = $handler->getTransform ( $image ,$path,$IP.$path.$hash.".png",$params ) ;

  $txt  = "<a href=$pname><img src=\"".$path.$hash.".png"."\"  width='".$boxwidth."' height='".$boxheight."' ></a>";
  return $txt;

instead of

  $txt  = "<iframe src=$pname width='".$boxwidth."' height='".$boxheight."' ></iframe>";
  return $txt;

but the image is not transformed. - I do not find the .png file.

Security risk[edit]

I am not sure about the warning about security, what's the difference between inline or a svg file? E.g. wikipedia allow SVG uploads. (IMHO) --Lastwebpage 00:08, 26 April 2011 (UTC)

you're right ! see below. STyx (talk) 17:29, 6 March 2017 (UTC)

Wiki SVG code editor[edit]

I think inline SVG code is a nice addition to Wiki, but the problem is inline code will complicate the syntax of the article page. This will reduce editing accessibility to rookie editor.

Instead I would like to ask if it's possible to invent an "edit SVG code" function to SVG file description page or just add a new namespace for storing code of a SVG image. The advantages of this function are: 1) easier management, if a SVG image is constantly vandalized admin can just protect it. 2) Since different website, browser or SVG tools applied different SVG renderers, meaning the rendering result can be different from 1 engine to another, allow editing code of the SVG file in Wiki means we can also instantly preview the image rendered by SVG renderer of Wiki. Without this function I have to upload the SVG again and again just for a perfect positioning of text.

I know there's Extension:AnyWikiDraw but editing code is prefered for accuracy. Of course adapting AnyWikiDraw into Wiki SVG code editor is also a good idea. -- Sameboat 02:13, 9 June 2011 (UTC)

I disagree ; see below. STyx (talk) 17:29, 6 March 2017 (UTC)

Inline SVG code is great ![edit]

What's the difference between inline code or a uploaded files ? none ! Security issues only depends on how this code is parsed and controlled by mediawiki. May be Extension:inline SVG is risky, but this problem can't be solved, in the same way, it was solved for uploaded files.

Inline SVG code is much better than Extension:AnyWikiDraw because mediawiki+parserfunctions(+loops) are much powerful than inkscape,..,M4,xslt,gnuplot,... Of course, inline SVG code is not for rookie ; but SVG is not for rookie anyway.

I developpe (on a private server) a set of templates to draw SVG, especially to draw graphs (graph's theory), and its works great ! STyx (talk) 17:29, 6 March 2017 (UTC)

Why the security problem can't be solved, in the same way, it was solved for uploaded files?
Is this extension do the same thing as been requested in https://phabricator.wikimedia.org/T26071?
--Ans (talk) 11:17, 16 December 2019 (UTC)