h5p-editor-php-library icon indicating copy to clipboard operation
h5p-editor-php-library copied to clipboard

Allowed uploading .svg files as images.

Open pjotrsavitski opened this issue 6 years ago • 2 comments

This should be a working solution work with well formatted svg images (exported from graphical editors). It assumes the presence of width and height or viewBox attributes (grabbing values from the first available source).

In case of width and height, the code mostly assumes the use of pixels, though it just strips any symbols that do not seem to be a number (this could still lead to strange consequences with regard to size).

For the viewBox case, it does just assume only plain numbers being present.

Every value is checked to be greater than zero. If the size is not in pixels, it should still be mostly working, due to ratio being correct (although not the values themselves).

One additional requirement is the SimpleXML extension, used for reading the files and extracting the attributes (one could also add a way to extract those with multiple different libraries, depending on which one being present).

It should be noted, that svgz files are not supported. Those could have issues with in-browser editor or some other aspects of the system, it would also require unzipping the XML content of the file first.

pjotrsavitski avatar Aug 07 '17 14:08 pjotrsavitski