Save oEmbed photo references as thumbnails if there's not a separate thumbnail_url entry in the return data. This fixes thumb saving for Flickr photo references.

This commit is contained in:
Brion Vibber 2010-11-12 14:03:08 -08:00
parent 65eeb7cba5
commit 2c4313467f
2 changed files with 16 additions and 5 deletions

View File

@ -120,7 +120,7 @@ class File_oembed extends Memcached_DataObject
} }
} }
$file_oembed->insert(); $file_oembed->insert();
if (!empty($data->thumbnail_url)) { if (!empty($data->thumbnail_url) || ($data->type == 'photo')) {
$ft = File_thumbnail::staticGet('file_id', $file_id); $ft = File_thumbnail::staticGet('file_id', $file_id);
if (!empty($ft)) { if (!empty($ft)) {
common_log(LOG_WARNING, "Strangely, a File_thumbnail object exists for new file $file_id", common_log(LOG_WARNING, "Strangely, a File_thumbnail object exists for new file $file_id",

View File

@ -55,10 +55,21 @@ class File_thumbnail extends Memcached_DataObject
* @param int $file_id * @param int $file_id
*/ */
public static function saveNew($data, $file_id) { public static function saveNew($data, $file_id) {
self::saveThumbnail($file_id, if (!empty($data->thumbnail_url)) {
$data->thumbnail_url, // Non-photo types such as video will usually
$data->thumbnail_width, // show us a thumbnail, though it's not required.
$data->thumbnail_height); 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);
}
} }
/** /**