]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Oembed bugs with thumbnail generation.
authorMikael Nordfeldth <mmn@hethane.se>
Mon, 18 Apr 2016 13:33:20 +0000 (15:33 +0200)
committerMikael Nordfeldth <mmn@hethane.se>
Mon, 18 Apr 2016 13:33:20 +0000 (15:33 +0200)
plugins/Oembed/actions/oembed.php

index c374b8b34f72c9cea758726e5108660ab3fe0391..564e492e4aeeb77ef276070154adfe5ee7bad182 100644 (file)
@@ -84,26 +84,25 @@ class OembedAction extends Action
             $oembed['html']=$notice->getRendered();
 
                        // maybe add thumbnail
-                       $attachments = $notice->attachments();
-                       if (!empty($attachments)) {
-                               foreach ($attachments as $attachment) {
-                                       if(is_object($attachment)) {
-                                               try {
-                                                       $thumb = $attachment->getThumbnail();
-                                               } catch (ServerException $e) {
-                                                       //
-                                               }
-                                               try {
-                                                       $thumb_url = File_thumbnail::url($thumb->filename);
-                                                       $oembed['thumbnail_url'] = $thumb_url;
-                                                       break; // only first one
-                                               } catch (ClientException $e) {
-                                                       //
-                                               }
-                                       }
-                               }
-                       }   
-                             
+            foreach ($notice->attachments() as $attachment) {
+                if (!$attachment instanceof File) {
+                    common_debug('ATTACHMENTS array entry from notice id=='._ve($notice->getID()).' is something else than a File dataobject: '._ve($attachment));
+                    continue;
+                }
+                try {
+                    $thumb = $attachment->getThumbnail();
+                    $thumb_url = File_thumbnail::url($thumb->filename);
+                    $oembed['thumbnail_url'] = $thumb_url;
+                    break;  // only first one
+                } catch (UseFileAsThumbnailException $e) {
+                    $oembed['thumbnail_url'] = $attachment->getUrl();
+                    break;  // we're happy with that
+                } catch (ServerException $e) {
+                    //
+                } catch (ClientException $e) {
+                    //
+                }
+            }
             break;
 
         case 'attachment':