Added few more mime type that needs over-ride
authorPradeep Nayak <pradpnayak@gmail.com>
Tue, 5 Feb 2019 19:40:36 +0000 (19:40 +0000)
committerPradeep Nayak <pradpnayak@gmail.com>
Tue, 5 Feb 2019 21:06:18 +0000 (21:06 +0000)
CRM/Utils/File.php

index 8f91b763d949a3549e63de3a9de482cd11223b7c..34eba794ab704a18a76dd95c583bb0a160b293f7 100644 (file)
@@ -918,7 +918,18 @@ HTACCESS;
       $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',
+    ];
+    $mimeType = 'image/' . CRM_Utils_Array::value(
+      $fileExtension,
+      $translateMimeTypes,
+      $fileExtension
+    );
 
     return self::getFileURL($path, $mimeType, $url);
   }