]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
[Embed] Hide error from the UI and just don't display an image if the remote image...
authorMiguel Dantas <biodantasgs@gmail.com>
Sat, 13 Jul 2019 01:56:47 +0000 (02:56 +0100)
committerDiogo Cordeiro <diogo@fc.up.pt>
Sat, 3 Aug 2019 16:49:10 +0000 (17:49 +0100)
lib/imagefile.php
plugins/Embed/EmbedPlugin.php

index 590f95a73923c6ce2ddda16ebc88c94130c6aeb6..2d7e85e28c0f60fb23eed50cc49e7d225c38fb57 100644 (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
index c7cf4d228c2a89fda8f2ecbbeb2d8fffc92477bf..d623e10ae90b0d2169ffc7f87b595f057843cdab 100644 (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);
     }
 
     /**