]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
add a thumbnail to oembed response
authorhannes <h@nnesmannerhe.im>
Thu, 21 Jan 2016 18:48:30 +0000 (18:48 +0000)
committerhannes <h@nnesmannerhe.im>
Thu, 21 Jan 2016 18:48:30 +0000 (18:48 +0000)
plugins/Oembed/actions/oembed.php

index 88ba52aa9f50b415dd2333553a05b005da2817ce..af181ad58686bad5ceb1170a2b8786e914c31585 100644 (file)
@@ -89,6 +89,28 @@ class OembedAction extends Action
             $oembed['author_url']=$profile->profileurl;
             $oembed['url']=$notice->getUrl();
             $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) {
+                                                       //
+                                               }
+                                       }
+                               }
+                       }   
+                             
             break;
 
         case 'attachment':
@@ -234,4 +256,4 @@ class OembedAction extends Action
     {
         return true;
     }
-}
+}
\ No newline at end of file