Pass file attachment thumbnails along with oEmbed data.

This commit is contained in:
Brion Vibber 2010-11-08 17:22:01 -08:00
parent c36fecb794
commit 6d7f02ff31
2 changed files with 16 additions and 0 deletions

View 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',

View 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);
}
}