This commit is contained in:
redmatrix
2015-10-28 16:59:23 -07:00
2 changed files with 11 additions and 2 deletions

View File

@@ -546,11 +546,18 @@ function guess_image_type($filename, $headers = '') {
$ext = pathinfo($filename, PATHINFO_EXTENSION);
$ph = photo_factory('');
$types = $ph->supportedTypes();
$type = "image/jpeg";
foreach ($types as $m=>$e){
if ($ext==$e) $type = $m;
}
}
if(is_null($type)) {
$size = getimagesize($filename);
$ph = photo_factory('');
$types = $ph->supportedTypes();
$type = ((array_key_exists($size['mime'], $types)) ? $size['mime'] : 'image/jpeg');
}
}
logger('Photo: guess_image_type: type='.$type, LOGGER_DEBUG);
return $type;