]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Pass file attachment thumbnails along with oEmbed data.
authorBrion Vibber <brion@status.net>
Tue, 9 Nov 2010 01:22:01 +0000 (17:22 -0800)
committerBrion Vibber <brion@status.net>
Tue, 9 Nov 2010 01:22:01 +0000 (17:22 -0800)
actions/oembed.php
classes/File.php

index da3aa0c716c8d313881cc5bc1ec8c1e22a6b1c8a..11d814583701a78a23392042b8dd861618e8f532 100644 (file)
@@ -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',
index e3b922d13b8efc000971f68a0714e5f260783385..56bc73ab257d4d40948f4cc1dcfb7e5e826250c2 100644 (file)
@@ -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);
+    }
 }