]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
[OEMBED][UI] Skip adding an image thumbnail for oembed results if we
authorMiguel Dantas <biodantasgs@gmail.com>
Fri, 28 Jun 2019 00:44:51 +0000 (01:44 +0100)
committerDiogo Cordeiro <diogo@fc.up.pt>
Sat, 3 Aug 2019 16:31:42 +0000 (17:31 +0100)
don't have a file locally to generate it, which can happen, for
instance, if StoreRemoteMedia is disabled

actions/attachment_thumbnail.php
lib/imagefile.php

index 3e5fbf222f915188e17ea4cac6806a2c72da2fbc..f0a54883b12528e256666b6815d9f8012a5dc063 100644 (file)
@@ -72,9 +72,12 @@ class Attachment_thumbnailAction extends AttachmentAction
                 $filepath = $file->getPath();
                 $size = $file->size;
             }
-        } catch (InvalidFilenameException $e) {
+            // XXX PHP: Upgrade to PHP 7.1
+            // FileNotFoundException | InvalidFilenameException
+        } catch (Exception $e) {
             // We don't have a file to display
-            return;
+            $this->clientError(_('No such attachment.'), 404);
+            return false;
         }
 
         $filename = MediaFile::getDisplayName($file);
index 2138a03e60f8c1721309c1f5c3a30eae489c2ab5..1bbadd0b244b42e3f810d2c2a5dfe9b5daf0b19b 100644 (file)
@@ -535,6 +535,11 @@ class ImageFile extends MediaFile
             throw new ServerException('No File object attached to this ImageFile object.');
         }
 
+        // File not stored locally, can't generate a thumbnail
+        if (empty($this->fileRecord->filename)) {
+            throw new FileNotStoredLocallyException($this->fileRecord);
+        }
+
         if ($width === null) {
             $width  = common_config('thumbnail', 'width');
             $height = common_config('thumbnail', 'height');