h5p-editor-php-library
h5p-editor-php-library copied to clipboard
Allowed uploading .svg files as images.
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.
Thanks a lot!
Issue for merging in: https://h5ptechnology.atlassian.net/browse/HFP-1348
With minimal changes (around getimagesize) this is still valid code. Thank you very much. Image-Hotspots look really nice now :)