diff options
author | Tim Almdal <tnalmdal@shaw.ca> | 2008-11-19 22:45:30 +0000 |
---|---|---|
committer | Tim Almdal <tnalmdal@shaw.ca> | 2008-11-19 22:45:30 +0000 |
commit | 103bd8e8d22fed0cb2795ba28fe2e5acbfc4c744 (patch) | |
tree | 6232c8caaf646c990a51fe3883dd7d03a65fdcc3 | |
parent | c8dc84d50230e6eb5e9824687ae57319b9afe05c (diff) |
Add the original item height and width to the item table
-rw-r--r-- | core/helpers/core_installer.php | 2 | ||||
-rw-r--r-- | core/helpers/photo.php | 2 | ||||
-rw-r--r-- | core/models/item.php | 3 | ||||
-rw-r--r-- | core/tests/Photo_Helper_Test.php | 8 |
4 files changed, 11 insertions, 4 deletions
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php index d0162b9b..e0e4f7d9 100644 --- a/core/helpers/core_installer.php +++ b/core/helpers/core_installer.php @@ -50,6 +50,8 @@ class core_installer { `right` int(9) NOT NULL, `parent_id` int(9) NOT NULL, `level` int(9) NOT NULL, + `width` int(9) default NULL, + `height` int(9) default NULL, `thumbnail_width` int(9) default NULL, `thumbnail_height` int(9) default NULL, `resize_width` int(9) default NULL, diff --git a/core/helpers/photo.php b/core/helpers/photo.php index cd02696d..958e432a 100644 --- a/core/helpers/photo.php +++ b/core/helpers/photo.php @@ -56,6 +56,8 @@ class Photo_Core { $photo->description = $description; $photo->name = $name; $photo->owner_id = $owner_id; + $photo->width = $image_info[0]; + $photo->height = $image_info[1]; $photo->mime_type = empty($image_info['mime']) ? "application/unknown" : $image_info['mime']; // Randomize the name if there's a conflict diff --git a/core/models/item.php b/core/models/item.php index f03d1a91..298557e9 100644 --- a/core/models/item.php +++ b/core/models/item.php @@ -191,9 +191,6 @@ class Item_Model extends ORM_MPTT { } catch (Exception $e) { return null; } - } else if ($column == "height" || $column == "width") { - $dims = getimagesize($this->file_path()); - return $column == "width" ? $dims[0] : $dims[1]; } else { return parent::__get($column); } diff --git a/core/tests/Photo_Helper_Test.php b/core/tests/Photo_Helper_Test.php index bef38a12..4c804a6f 100644 --- a/core/tests/Photo_Helper_Test.php +++ b/core/tests/Photo_Helper_Test.php @@ -20,7 +20,11 @@ class Photo_Helper_Test extends Unit_Test_Case { public function create_photo_test() { $rand = rand(); - $photo = photo::create(1, DOCROOT . "core/tests/test.jpg", "$rand.jpg", $rand, $rand); + + $filename = DOCROOT . "core/tests/test.jpg"; + $image_info = getimagesize($filename); + + $photo = photo::create(1, $filename, "$rand.jpg", $rand, $rand); $this->assert_equal(VARPATH . "albums/$rand.jpg", $photo->file_path()); $this->assert_equal(VARPATH . "resizes/{$rand}.thumb.jpg", $photo->thumbnail_path()); @@ -35,6 +39,8 @@ class Photo_Helper_Test extends Unit_Test_Case { $this->assert_equal($rand, $photo->title); $this->assert_equal($rand, $photo->description); $this->assert_equal("image/jpeg", $photo->mime_type); + $this->assert_equal($image_info[0], $photo->width); + $this->assert_equal($image_info[1], $photo->height); $this->assert_equal($photo->parent()->right - 2, $photo->left); $this->assert_equal($photo->parent()->right - 1, $photo->right); |