summaryrefslogtreecommitdiff
path: root/core/helpers
diff options
context:
space:
mode:
Diffstat (limited to 'core/helpers')
-rw-r--r--core/helpers/album.php13
-rw-r--r--core/helpers/core_installer.php4
-rw-r--r--core/helpers/photo.php15
3 files changed, 25 insertions, 7 deletions
diff --git a/core/helpers/album.php b/core/helpers/album.php
index 021c09f3..6934932e 100644
--- a/core/helpers/album.php
+++ b/core/helpers/album.php
@@ -54,4 +54,17 @@ class Album_Core {
}
return $album;
}
+
+ static function set_thumbnail($id, $filename) {
+ $album = ORM::factory("item", $id);
+
+ /** @todo: parameterize these dimensions */
+ $image = Image::factory($filename);
+ $image->resize(200, 140, Image::WIDTH)->save($album->thumbnail_path());
+
+ $dims = getimagesize($album->thumbnail_path());
+ $album->thumbnail_width = $dims[0];
+ $album->thumbnail_height = $dims[1];
+ return $album->save();
+ }
}
diff --git a/core/helpers/core_installer.php b/core/helpers/core_installer.php
index 7d83236a..bbcf9bd1 100644
--- a/core/helpers/core_installer.php
+++ b/core/helpers/core_installer.php
@@ -49,6 +49,10 @@ class core_installer {
`right` int(9) NOT NULL,
`parent_id` int(9) NOT NULL,
`level` int(9) NOT NULL,
+ `thumbnail_width` int(9) default NULL,
+ `thumbnail_height` int(9) default NULL,
+ `resize_width` int(9) default NULL,
+ `resize_height` int(9) default NULL,
PRIMARY KEY (`id`),
KEY `parent_id` (`parent_id`),
KEY `type` (`type`))
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();
}
}