]> git.mxchange.org Git - quix0rs-gnu-social.git/commitdiff
Save oEmbed photo references as thumbnails if there's not a separate thumbnail_url...
authorBrion Vibber <brion@status.net>
Fri, 12 Nov 2010 22:03:08 +0000 (14:03 -0800)
committerBrion Vibber <brion@status.net>
Fri, 12 Nov 2010 22:03:08 +0000 (14:03 -0800)
classes/File_oembed.php
classes/File_thumbnail.php

index a5540ecfee5de54f87b2c323feaba82f624c9e9b..bcb2f7bacc432fde7548d25450338749645b92b4 100644 (file)
@@ -120,7 +120,7 @@ class File_oembed extends Memcached_DataObject
             }
         }
         $file_oembed->insert();
-        if (!empty($data->thumbnail_url)) {
+        if (!empty($data->thumbnail_url) || ($data->type == 'photo')) {
             $ft = File_thumbnail::staticGet('file_id', $file_id);
             if (!empty($ft)) {
                 common_log(LOG_WARNING, "Strangely, a File_thumbnail object exists for new file $file_id",
index d371b9e8aa2f783871c147408978edf79ac96593..17bac7f08c024e264dcae9913458500cfe612307 100644 (file)
@@ -55,10 +55,21 @@ class File_thumbnail extends Memcached_DataObject
      * @param int $file_id
      */
     public static function saveNew($data, $file_id) {
-        self::saveThumbnail($file_id,
-                            $data->thumbnail_url,
-                            $data->thumbnail_width,
-                            $data->thumbnail_height);
+        if (!empty($data->thumbnail_url)) {
+            // Non-photo types such as video will usually
+            // show us a thumbnail, though it's not required.
+            self::saveThumbnail($file_id,
+                                $data->thumbnail_url,
+                                $data->thumbnail_width,
+                                $data->thumbnail_height);
+        } else if ($data->type == 'photo') {
+            // The inline photo URL given should also fit within
+            // our requested thumbnail size, per oEmbed spec.
+            self::saveThumbnail($file_id,
+                                $data->url,
+                                $data->width,
+                                $data->height);
+        }
     }
 
     /**