diff options
author | Brion Vibber <brion@status.net> | 2010-11-08 17:20:04 -0800 |
---|---|---|
committer | Brion Vibber <brion@status.net> | 2010-11-08 17:20:04 -0800 |
commit | c36fecb79431218016615cde45215337d67fee67 (patch) | |
tree | daedc113463f47c3d22410499c89b186d431580c /classes/File_thumbnail.php | |
parent | dc497ed090d94561db195983a4346a2f66503422 (diff) |
Save a thumbnail image when uploading an image file into the file attachments system. Currently hardcoded to 100x75, needs aspect-sensitivity etc.
Diffstat (limited to 'classes/File_thumbnail.php')
-rw-r--r-- | classes/File_thumbnail.php | 30 |
1 files changed, 26 insertions, 4 deletions
diff --git a/classes/File_thumbnail.php b/classes/File_thumbnail.php index edae8ac21..d371b9e8a 100644 --- a/classes/File_thumbnail.php +++ b/classes/File_thumbnail.php @@ -48,12 +48,34 @@ class File_thumbnail extends Memcached_DataObject return array(false, false, false); } - function saveNew($data, $file_id) { + /** + * Save oEmbed-provided thumbnail data + * + * @param object $data + * @param int $file_id + */ + public static function saveNew($data, $file_id) { + self::saveThumbnail($file_id, + $data->thumbnail_url, + $data->thumbnail_width, + $data->thumbnail_height); + } + + /** + * Save a thumbnail record for the referenced file record. + * + * @param int $file_id + * @param string $url + * @param int $width + * @param int $height + */ + static function saveThumbnail($file_id, $url, $width, $height) + { $tn = new File_thumbnail; $tn->file_id = $file_id; - $tn->url = $data->thumbnail_url; - $tn->width = intval($data->thumbnail_width); - $tn->height = intval($data->thumbnail_height); + $tn->url = $url; + $tn->width = intval($width); + $tn->height = intval($height); $tn->insert(); } } |