[OEMBED][UI] Skip adding an image thumbnail for oembed results if we

don't have a file locally to generate it, which can happen, for
instance, if StoreRemoteMedia is disabled
This commit is contained in:
Miguel Dantas 2019-06-28 01:44:51 +01:00 committed by Diogo Cordeiro
parent da82048d77
commit 4187568522
2 changed files with 10 additions and 2 deletions

View File

@ -72,9 +72,12 @@ class Attachment_thumbnailAction extends AttachmentAction
$filepath = $file->getPath(); $filepath = $file->getPath();
$size = $file->size; $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 // We don't have a file to display
return; $this->clientError(_('No such attachment.'), 404);
return false;
} }
$filename = MediaFile::getDisplayName($file); $filename = MediaFile::getDisplayName($file);

View File

@ -535,6 +535,11 @@ class ImageFile extends MediaFile
throw new ServerException('No File object attached to this ImageFile object.'); 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) { if ($width === null) {
$width = common_config('thumbnail', 'width'); $width = common_config('thumbnail', 'width');
$height = common_config('thumbnail', 'height'); $height = common_config('thumbnail', 'height');