forked from GNUsocial/gnu-social
Testing... using photo info for temp thumbnails
This commit is contained in:
parent
551b196a35
commit
a2994e3aa2
@ -352,11 +352,10 @@ class File extends Memcached_DataObject
|
|||||||
$mimetype = substr($mimetype,0,$semicolon);
|
$mimetype = substr($mimetype,0,$semicolon);
|
||||||
}
|
}
|
||||||
if(in_array($mimetype,$notEnclosureMimeTypes)){
|
if(in_array($mimetype,$notEnclosureMimeTypes)){
|
||||||
// Never treat HTML as an enclosure type!
|
// Never treat generic HTML links as an enclosure type!
|
||||||
return false;
|
// But if we have oEmbed info, we'll consider it golden.
|
||||||
} else {
|
|
||||||
$oembed = File_oembed::staticGet('file_id',$this->id);
|
$oembed = File_oembed::staticGet('file_id',$this->id);
|
||||||
if($oembed){
|
if($oembed && in_array($oembed->type, array('photo', 'video'))){
|
||||||
$mimetype = strtolower($oembed->mimetype);
|
$mimetype = strtolower($oembed->mimetype);
|
||||||
$semicolon = strpos($mimetype,';');
|
$semicolon = strpos($mimetype,';');
|
||||||
if($semicolon){
|
if($semicolon){
|
||||||
|
@ -212,19 +212,30 @@ class AttachmentListItem extends Widget
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Pull a thumbnail image reference for the given file.
|
||||||
|
* In order we check:
|
||||||
|
* 1) file_thumbnail table (thumbnails found via oEmbed)
|
||||||
|
* 2) image URL from direct dereference or oEmbed 'photo' type URL
|
||||||
|
* 3) ???
|
||||||
|
*
|
||||||
|
* @return mixed object with (url, width, height) properties, or false
|
||||||
|
*/
|
||||||
function getThumbInfo()
|
function getThumbInfo()
|
||||||
{
|
{
|
||||||
$thumbnail = File_thumbnail::staticGet('file_id', $this->attachment->id);
|
$thumbnail = File_thumbnail::staticGet('file_id', $this->attachment->id);
|
||||||
if ($thumbnail) {
|
if ($thumbnail) {
|
||||||
return $thumbnail;
|
return $thumbnail;
|
||||||
} else {
|
}
|
||||||
switch ($this->attachment->mimetype) {
|
$enc = $this->attachment->getEnclosure();
|
||||||
|
if ($enc) {
|
||||||
|
switch ($enc->mimetype) {
|
||||||
case 'image/gif':
|
case 'image/gif':
|
||||||
case 'image/png':
|
case 'image/png':
|
||||||
case 'image/jpg':
|
case 'image/jpg':
|
||||||
case 'image/jpeg':
|
case 'image/jpeg':
|
||||||
$thumb = (object)array();
|
$thumb = (object)array();
|
||||||
$thumb->url = $this->attachment->url;
|
$thumb->url = $enc->url;
|
||||||
$thumb->width = 100;
|
$thumb->width = 100;
|
||||||
$thumb->height = 75; // @fixme
|
$thumb->height = 75; // @fixme
|
||||||
return $thumb;
|
return $thumb;
|
||||||
|
Loading…
Reference in New Issue
Block a user