Commit 981e86f5 authored by Nigel McNie's avatar Nigel McNie

(#3247) Make exif extension optional by using getimagesize() when exif isn't available.

According to the documentation, getimagesize is slower, but will return the same result for filetype.
parent ac1730b6
......@@ -358,8 +358,17 @@ function is_image_type($type) {
* @return boolean Whether the file is a valid image file for Mahara
*/
function is_image_file($path) {
if (!$type = exif_imagetype($path)) {
return false;
if (function_exists('exif_imagetype')) {
// exif_imagetype is faster
if (!$type = exif_imagetype($path)) {
return false;
}
}
else {
// getimagesize returns the same answer
if (!list ($width, $height, $type) = getimagesize($path)) {
return false;
}
}
return is_image_type($type);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment