]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Try to get mime data before hashing (cpu intensive)
authorMikael Nordfeldth <mmn@hethane.se>
Thu, 25 Feb 2016 21:31:45 +0000 (22:31 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Thu, 25 Feb 2016 21:31:45 +0000 (22:31 +0100)
plugins/Oembed/OembedPlugin.php

index 44e4ac93180679d1baccba90fb6bb66bc74a25b8..196b07d75d0d57fa2a5bfc8f98204b8587ef565e 100644 (file)
@@ -325,8 +325,10 @@ class OembedPlugin extends Plugin
             throw new UnsupportedMediaException(_('Image file had impossible geometry (0 width or height)'));
         }
 
+        $ext = File::guessMimeExtension($info['mime']);
+
         // We'll trust sha256 (File::FILEHASH_ALG) not to have collision issues any time soon :)
-        $filename = hash(File::FILEHASH_ALG, $imgData) . '.' . common_supported_mime_to_ext($info['mime']);
+        $filename = hash(File::FILEHASH_ALG, $imgData) . ".{$ext}";
         $fullpath = File_thumbnail::path($filename);
         // Write the file to disk. Throw Exception on failure
         if (!file_exists($fullpath) && file_put_contents($fullpath, $imgData) === false) {