]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Testing... using photo info for temp thumbnails
authorBrion Vibber <brion@status.net>
Mon, 8 Nov 2010 23:50:06 +0000 (15:50 -0800)
committerBrion Vibber <brion@status.net>
Mon, 8 Nov 2010 23:50:06 +0000 (15:50 -0800)
classes/File.php
lib/attachmentlist.php

index d71403e64905527b4fd6b418acc32ae607c6b156..e3b922d13b8efc000971f68a0714e5f260783385 100644 (file)
@@ -352,11 +352,10 @@ class File extends Memcached_DataObject
                 $mimetype = substr($mimetype,0,$semicolon);
             }
             if(in_array($mimetype,$notEnclosureMimeTypes)){
-                // Never treat HTML as an enclosure type!
-                return false;
-            } else {
+                // Never treat generic HTML links as an enclosure type!
+                // But if we have oEmbed info, we'll consider it golden.
                 $oembed = File_oembed::staticGet('file_id',$this->id);
-                if($oembed){
+                if($oembed && in_array($oembed->type, array('photo', 'video'))){
                     $mimetype = strtolower($oembed->mimetype);
                     $semicolon = strpos($mimetype,';');
                     if($semicolon){
index f29d32ada31bccd0cf7b5df4c18b5c0b24810476..8e6ad038a3a8679e94b614970ac518e926614da3 100644 (file)
@@ -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()
     {
         $thumbnail = File_thumbnail::staticGet('file_id', $this->attachment->id);
         if ($thumbnail) {
             return $thumbnail;
-        } else {
-            switch ($this->attachment->mimetype) {
+        }
+        $enc = $this->attachment->getEnclosure();
+        if ($enc) {
+            switch ($enc->mimetype) {
                 case 'image/gif':
                 case 'image/png':
                 case 'image/jpg':
                 case 'image/jpeg':
                     $thumb = (object)array();
-                    $thumb->url = $this->attachment->url;
+                    $thumb->url = $enc->url;
                     $thumb->width = 100;
                     $thumb->height = 75; // @fixme
                     return $thumb;