SVG is not displayed when adding in html editor

SVG is not displayed when adding in html editor

by Eugene Vandyshev -
Number of replies: 4

Hello guys, could you please help me with the following issue:

I want to add graphics using svg in a moodle course. (it must be svg, so i sorta have no alternative)

When i add a page in add resource section code doesn't display at all.

when i click save and display nothing appears as well.

when i publish my data using a file in add resource section everything works fine.

id like to have an ability to use svg in page publishing.

could you please help me with that?

moodle 2.0, Mac OS X, Opera and FireFox.

thanks in advance.

Average of ratings: -
In reply to Eugene Vandyshev

Re: SVG is not displayed when adding in html editor

by Mauno Korpelainen -

Moodle has several settings that filter or clean code (for example in
Site administration > Security >  Site policies and in editor/editor plugins for HTML purifier, allowed tags, allowing EMBED/OBJECT tags, enable trusted content,... ).

Furthermore different browsers have only partial support for different kinds of ways to add svg...

The best way to add pure svg might be to use external files (inside moodle or somewhere in www pages) could be code like

<object data="http://upload.wikimedia.org/wikipedia/commons/5/54/Ford_circles.svg" height="531" width="531">
<param name="src" value="http://upload.wikimedia.org/wikipedia/commons/5/54/Ford_circles.svg" /><img src="http://upload.wikimedia.org/wikipedia/commons/thumb/5/54/Ford_circles.svg/531px-Ford_circles.svg.png" width="531" height="531"  />
</object>

that is using a svg image http://upload.wikimedia.org/wikipedia/commons/5/54/Ford_circles.svg for those browsers that can show svg with object tags that validate in XHTML and a fallback image for IE ( < IE9 )

You may need to disable editor from your user profile before adding those object tags (When editing text - Use standard web forms) because media plugin in tinymce may not like this type of object tags.

Adding svg directly to html might need a different doc type (HTML5) but HTML5 support is not yet implemented to moodle.

And using links to external files works in any case...

In reply to Mauno Korpelainen

Re: SVG is not displayed when adding in html editor

by Eugene Vandyshev -

i found that you can build plots with JSXGraph plugin, am i right that it has an ability to export result in SVG format?

if so, do u think its a good way of creating a geometry course in moode, combining it with mathml?

if its not hard, could you please give a tutorial of installing JSXGraph plugin in moode?

thanks in advance

In reply to Mauno Korpelainen

Re: SVG is not displayed when adding in html editor

by Eugene Vandyshev -

It works with object tag when i insert a link to an image located on some website, but when i try to add an .svg file with simple code from a local folder located in /Documents it doesn't appear after i save and display.

(

<p><object data="/Users/eugenevandyshev/Documents/m1.svg" type="image/svg+xml" height="200" width="300"></object></p>

)

maybe i should put the file somewhere else?

In reply to Eugene Vandyshev

Re: SVG is not displayed when adding in html editor

by Eugene Vandyshev -

got it working!

should have been like that

<object data="http://localhost:8888/moodle20/m1.svg" type="image/svg+xml" height="200" width="300">

Mauno! thanks again for help!