From: Miguel Dantas Date: Sat, 13 Jul 2019 01:56:47 +0000 (+0100) Subject: [Embed] Hide error from the UI and just don't display an image if the remote image... X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=07b4cfaeae3b4b429ab4cc1091f9c0478acb2983;p=quix0rs-gnu-social.git [Embed] Hide error from the UI and just don't display an image if the remote image is not valid --- diff --git a/lib/imagefile.php b/lib/imagefile.php index 590f95a739..2d7e85e28c 100644 --- a/lib/imagefile.php +++ b/lib/imagefile.php @@ -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 diff --git a/plugins/Embed/EmbedPlugin.php b/plugins/Embed/EmbedPlugin.php index c7cf4d228c..d623e10ae9 100644 --- a/plugins/Embed/EmbedPlugin.php +++ b/plugins/Embed/EmbedPlugin.php @@ -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); } /**