diff --git a/inc/imce.page.inc b/inc/imce.page.inc index 7ce35f6..4c67bd2 100644 --- a/inc/imce.page.inc +++ b/inc/imce.page.inc @@ -678,11 +678,22 @@ function imce_validate_quotas($file, &$imce, $add = 0) { /** * Check if the file is an image and return info. */ -function imce_image_info($file) { - if (is_file($file) && ($dot = strrpos($file, '.')) && in_array(strtolower(substr($file, $dot+1)), array('jpg', 'jpeg', 'gif', 'png')) && ($info = @getimagesize($file)) && in_array($info[2], array(IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG)) ) { - return array('width' => $info[0], 'height' => $info[1], 'type' => $info[2], 'mime' => $info['mime']); +if (variable_get('imce_image_get_info', 0)) { + function imce_image_info($file) { + $mimes = array('image/jpeg' => IMAGETYPE_JPEG, 'image/gif' => IMAGETYPE_GIF, 'image/png' => IMAGETYPE_PNG); + if (is_file($file) && ($dot = strrpos($file, '.')) && in_array(strtolower(substr($file, $dot+1)), array('jpg', 'jpeg', 'gif', 'png')) && ($info = @image_get_info($file)) && isset($mimes[$info['mime_type']]) ) { + return array('width' => $info['width'], 'height' => $info['height'], 'type' => $mimes[$info['mime_type']], 'mime' => $info['mime_type']); + } + return FALSE; + } +} +else { + function imce_image_info($file) { + if (is_file($file) && ($dot = strrpos($file, '.')) && in_array(strtolower(substr($file, $dot+1)), array('jpg', 'jpeg', 'gif', 'png')) && ($info = @getimagesize($file)) && in_array($info[2], array(IMAGETYPE_JPEG, IMAGETYPE_GIF, IMAGETYPE_PNG)) ) { + return array('width' => $info[0], 'height' => $info[1], 'type' => $info[2], 'mime' => $info['mime']); + } + return FALSE; } - return FALSE; } /**