Permalink
Browse files

Use exif_imagetype and image_type_to_mime_type when available

  • Loading branch information...
1 parent 6ca3183 commit 1779ec66a388ad41d72e9d42412fb923b0e400e5 @josegonzalez josegonzalez committed Oct 19, 2012
Showing with 12 additions and 1 deletion.
  1. +12 −1 Model/Behavior/UploadBehavior.php
@@ -1203,7 +1203,18 @@ public function _getMimeType($filePath) {
return $finfo->file($filePath);
}
- return mime_content_type($filePath);
+ if (function_exists('exif_imagetype') && function_exists('image_type_to_mime_type')) {
+ $mimetype = image_type_to_mime_type(exif_imagetype($filePath));
+ if ($mimetype !== false) {
+ return $mimetype;
+ }
+ }
+
+ if (function_exists('mime_content_type')) {
+ return mime_content_type($filePath);
+ }
+
+ return 'application/octet-stream';
}
public function _prepareFilesForDeletion(&$model, $field, $data, $options) {

0 comments on commit 1779ec6

Please sign in to comment.