]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Display locally stored remote GIFs as thumbnails
authorMikael Nordfeldth <mmn@hethane.se>
Tue, 8 Mar 2016 00:36:24 +0000 (01:36 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Tue, 8 Mar 2016 00:36:24 +0000 (01:36 +0100)
Many newspapers seem to use animated GIFs as catchy header images, which
we would fail to show from oEmbed/OpenGraph fetching since they would
want us to "use File as Thumbnail", but the only place the image filename
was stored was in File_thumbnail, for the thumbnail of that file_id which
had a URL set.

classes/File.php

index a1a2f78906e7056605a05bc80c757639d33174fb..66ebc26138ff8e2e4f265406c92af29a99c20755 100644 (file)
@@ -479,7 +479,13 @@ class File extends Managed_DataObject
             // null  means "always use file as thumbnail"
             // false means you get choice between frozen frame or original when calling getThumbnail
             if (is_null(common_config('thumbnail', 'animated')) || !$force_still) {
-                throw new UseFileAsThumbnailException($this->id);
+                try {
+                    // remote files with animated GIFs as thumbnails will match this
+                    return File_thumbnail::byFile($this);
+                } catch (NoResultException $e) {
+                    // and if it's not a remote file, it'll be safe to use the locally stored File
+                    throw new UseFileAsThumbnailException($this->id);
+                }
             }
         }