mahara-contributors team mailing list archive
-
mahara-contributors team
-
Mailing list archive
-
Message #23998
[Bug 1416890] Re: Use SVG images and provide backward compatibility
I agree with all your comments.
We already coded a method in Theme class in the lib/web.php file. It
doesn't have caching neither have support for IE8 and below but I think
it is simple and do the job:
/**
* Adds the URL of an image with the extension svg if it exists, png otherwise.
*
* @param string $filename The name of the file without the extension
* @param string $plugindirectory The plugin directory
* @return string The image URL with the correct file extension.
*/
public function get_image_url_with_extension($filename, $plugindirectory = '') {
$ext = '.png';
if (file_exists($this->_get_path($filename . '.svg', false, $plugindirectory, get_config('docroot')))) {
$ext = '.svg';
}
return $this->get_url($filename . $ext, false, $plugindirectory);
}
Note that it don't support the multi-files array possible with the
get_url param (second parameter) but I dont think its a problem.
I'm new to mahara and I don't know yet how to share with you but I may
create a Git branch if you want. We could maybe create the same for the
path, something like get_image_path_with_extension.
It should be great to have the same thing in javascript. That could be
another task too.
--
You received this bug notification because you are a member of Mahara
Contributors, which is subscribed to Mahara.
Matching subscriptions: Subscription for all Mahara Contributors -- please ask on #mahara-dev or mahara.org forum before editing or unsubscribing it!
https://bugs.launchpad.net/bugs/1416890
Title:
Use SVG images and provide backward compatibility
Status in Mahara ePortfolio:
Triaged
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
To manage notifications about this bug go to:
https://bugs.launchpad.net/mahara/+bug/1416890/+subscriptions
References