Use SVG images and provide backward compatibility
Bug #1416890 reported by
Kristina Hoeppner
This bug affects 4 people
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Mahara |
Fix Released
|
Wishlist
|
Gilles-Philippe Leblanc | ||
15.10 |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
Suggestion by Gilles-Philippe Leblanc:
In the Moodle software, the images are all managed by a cascade system.
The function initially looking if a svg file exists, then a png, then gif, jpg and ico.
This lets you use a svg file and maintain backward compatibility.
The system also detects if the browser supports SVG. Generally, all browsers support this format except Internet Explorer 8 and below.
Everything is cached to avoid unnecessary calculation.
So I was wondering if it was planned to add the following components to do this:
* A library for browser detection on the server side
* A function to find the right file extension
* A library for caching php
Changed in mahara: | |
milestone: | none → 15.04.0 |
status: | Triaged → In Progress |
milestone: | 15.04.0 → 15.10.0 |
Changed in mahara: | |
status: | In Progress → Confirmed |
status: | Confirmed → In Progress |
assignee: | nobody → Gilles-Philippe Leblanc (gilles-philippe-leblanc) |
Changed in mahara: | |
status: | In Progress → Fix Committed |
tags: | added: api theming |
Changed in mahara: | |
status: | Fix Committed → Fix Released |
To post a comment you must log in.
We don't have any immediate plans to do this, but if a person were to implement this, the place to start would be looking at the Theme class in lib/web.php. Currently images are served up with the $THEME->get_url() method, which abstracts out the specific theme to allow for theme inheritance. We'd need to add a second method alongside that abstracts out the file suffix for image files.
See https:/ /wiki.mahara. org/index. php/Customising /Themes/ 1.10#Core_ assets for details on how it currently works.
Cacheing it is a separate issue. Our theme system currently doesn't do any cacheing at all. Every time it's looking for a particular file, it hits the filesystem to find it. I haven't run any tests to see whether this causes us any slowdown, though. I suppose an easy way to test it would be to modify $THEME->get_url() so that it's hardcoded to use the "raw" theme instead of checking for the existence of files.
And the third issue is browser detection. We currently have a library that detects whether you're using a phone or table, but we don't do any browser sniffing beyond that. In fact, in the Mahara README we limit Mahara support to the latest versions of Firefox & Chrome, and the last three releases of IE (currently IE9, 10, and 11). All of those support SVG files: http:// caniuse. com/#feat= svg
So, we wouldn't be adding any code to Mahara core to check for browser support for SVGs. But if we did implement the file-format- abstracting system described above, we could add a local/lib.php hook in lib/web.php to allow sites have to support IE8 to customize the process of deciding which file format to use.