Skip to content

Commit

Permalink
Added few more mime type that needs over-ride
Browse files Browse the repository at this point in the history
  • Loading branch information
pradpnayak committed Feb 5, 2019
1 parent 878a913 commit 84c4449
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion CRM/Utils/File.php
Original file line number Diff line number Diff line change
Expand Up @@ -918,7 +918,17 @@ public static function getImageURL($imageURL) {
$path = $url = $imageURL;
}
$fileExtension = strtolower(pathinfo($path, PATHINFO_EXTENSION));
$mimeType = 'image/' . ($fileExtension == 'jpg' ? 'jpeg' : $fileExtension);
//According to (https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Complete_list_of_MIME_types),
// there are some extensions that would need translating.:
$translateMimeTypes = [
'tif' => 'tiff',
'jpg' => 'jpeg',
'svg' => 'svg+xml',
];
if (!empty($translateMimeTypes[$fileExtension])) {
$fileExtension = $translateMimeTypes[$fileExtension];
}
$mimeType = 'image/' . $fileExtension;

return self::getFileURL($path, $mimeType, $url);
}
Expand Down

0 comments on commit 84c4449

Please sign in to comment.