Commit 346e1911 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.
(cherry picked from commit 981e86f5)
parent 69113f1a
......@@ -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