From: Brion Vibber Date: Tue, 9 Nov 2010 01:22:01 +0000 (-0800) Subject: Pass file attachment thumbnails along with oEmbed data. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=6d7f02ff31c6c929223030b051541b1bf103f3a8;p=quix0rs-gnu-social.git Pass file attachment thumbnails along with oEmbed data. --- diff --git a/actions/oembed.php b/actions/oembed.php index da3aa0c716..11d8145837 100644 --- a/actions/oembed.php +++ b/actions/oembed.php @@ -112,6 +112,12 @@ class OembedAction extends Action //$oembed['width']= //$oembed['height']= $oembed['url']=$attachment->url; + $thumb = $attachment->getThumbnail(); + if ($thumb) { + $oembed['thumbnail_url'] = $thumb->url; + $oembed['thumbnail_width'] = $thumb->width; + $oembed['thumbnail_height'] = $thumb->height; + } }else{ $oembed['type']='link'; $oembed['url']=common_local_url('attachment', diff --git a/classes/File.php b/classes/File.php index e3b922d13b..56bc73ab25 100644 --- a/classes/File.php +++ b/classes/File.php @@ -384,4 +384,14 @@ class File extends Memcached_DataObject $enclosure = $this->getEnclosure(); return !empty($enclosure); } + + /** + * Get the attachment's thumbnail record, if any. + * + * @return File_thumbnail + */ + function getThumbnail() + { + return File_thumbnail::staticGet('file_id', $this->id); + } }