[Embed] Hide error from the UI and just don't display an image if the remote image is not valid

This commit is contained in:
Miguel Dantas 2019-07-13 02:56:47 +01:00 committed by Diogo Cordeiro
parent c9379b3608
commit 07b4cfaeae
2 changed files with 10 additions and 8 deletions

View File

@ -115,7 +115,7 @@ class ImageFile extends MediaFile
$media = common_get_mime_media($file->mimetype);
if (Event::handle('CreateFileImageThumbnailSource', array($file, &$imgPath, $media))) {
if (empty($file->filename) && !file_exists($imgPath)) {
throw new UnsupportedMediaException(_m('File without filename could not get a thumbnail source.'));
throw new FileNotFoundException($imgPath);
}
// First some mimetype specific exceptions

View File

@ -175,12 +175,12 @@ class EmbedPlugin extends Plugin
if (isset($url)) {
foreach (['xml', 'json'] as $format) {
$action->element('link',
array('rel' =>'alternate',
'type' => "application/{$format}+oembed",
'href' => common_local_url('oembed',
array(),
array('format' => $format, 'url' => $url)),
'title' => 'oEmbed'));
['rel' =>'alternate',
'type' => "application/{$format}+oembed",
'href' => common_local_url('oembed',
[],
['format' => $format, 'url' => $url]),
'title' => 'oEmbed']);
}
}
return true;
@ -291,6 +291,8 @@ class EmbedPlugin extends Plugin
$thumb = $file->getThumbnail(128, 128);
$out->element('img', $thumb->getHtmlAttrs(['class'=>'u-photo embed']));
unset($thumb);
} catch (FileNotFoundException $e){
// Nothing to show
} catch (Exception $e) {
$out->element('div', ['class'=>'error'], $e->getMessage());
}
@ -411,7 +413,7 @@ class EmbedPlugin extends Plugin
// Out
$imgPath = $thumbnail->getPath();
return false;
return !file_exists($imgPath);
}
/**