From ae00f739445717885e2fc82e241bae38b7e58d44 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Wed, 5 Nov 2008 09:42:47 +0000 Subject: * Add thumbnail and resize dimensions to the item table and use them properly in the theme. * Move thumbnail and resize generation down into the model for consistency. * Add a sample thumbnail for albums * Fix a bug in the ORM to clear the cache when we reload an object. * Add Kohana docs to the scaffold. --- core/helpers/photo.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'core/helpers/photo.php') diff --git a/core/helpers/photo.php b/core/helpers/photo.php index dfa67e2b..ef94f52b 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -52,14 +52,15 @@ class Photo_Core { $photo->name = rand() . "." . $pi["extension"]; } - $photo->add_to_parent($parent_id); - copy($filename, $photo->file_path()); - /** @todo: parameterize these values */ - $image = Image::factory($filename); - $image->resize(200, 140, Image::WIDTH)->save($photo->thumbnail_path()); - $image->resize(800, 600, Image::WIDTH)->save($photo->resize_path()); - return $photo; + // This saves the photo + $photo->add_to_parent($parent_id); + + /** @todo: parameterize these dimensions */ + // This saves the photo a second time, which is unfortunate but difficult to avoid. + return $photo->set_thumbnail($filename, 200, 140) + ->set_resize($filename, 800, 600) + ->save(); } } -- cgit v1.2.3