]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Hack to force thumbnail generation directly on upload
authorMikael Nordfeldth <mmn@hethane.se>
Fri, 23 Jan 2015 13:52:02 +0000 (14:52 +0100)
committerMikael Nordfeldth <mmn@hethane.se>
Fri, 23 Jan 2015 13:52:02 +0000 (14:52 +0100)
Remove this when we know that third party frontends like Qvitter have
improved attachment handling.

actions/apimediaupload.php

index be561b0bceed83f6f13e40426346210908ebfaa2..47d9744344b2f4475bbb825107549bfe651056a9 100644 (file)
@@ -75,6 +75,17 @@ class ApiMediaUploadAction extends ApiAuthAction
         // we could catch "NoUploadedMediaException" as "no media uploaded", but here we _always_ want an upload
         $upload = MediaFile::fromUpload('media', $this->scoped);
 
+        // Hack to make a thumbnail before giving back a response
+        // (the file should instead actually be attached to a notice in the file_to_post table)
+        try {
+            if ($upload->fileRecord instanceof File) {
+                $upload->fileRecord->getThumbnail();
+            }
+        } catch (Exception $e) {
+            common_debug(sprintf('A hack is buggy: MediaFile fileRecord could not getThumbnail for file id==%u',
+                                 $upload->fileRecord->id));
+        }
+
         $this->showResponse($upload);
     }