From: hannes Date: Thu, 21 Jan 2016 18:48:30 +0000 (+0000) Subject: add a thumbnail to oembed response X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d0e2f8745d9e22fa180a2a6ade3dcc88c209220c;p=quix0rs-gnu-social.git add a thumbnail to oembed response --- diff --git a/plugins/Oembed/actions/oembed.php b/plugins/Oembed/actions/oembed.php index 88ba52aa9f..af181ad586 100644 --- a/plugins/Oembed/actions/oembed.php +++ b/plugins/Oembed/actions/oembed.php @@ -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