summaryrefslogtreecommitdiff
path: root/modules/gallery/controllers/quick.php
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2010-08-07 22:18:28 -0700
committerBharat Mediratta <bharat@menalto.com>2010-08-07 22:18:28 -0700
commitdfb095a26267f8b68b40add03dfe407966c49b92 (patch)
tree3306c1bc1fd33fc888270b1c312771baed3b4aed /modules/gallery/controllers/quick.php
parent1abf43d3f1efa9d0d51f4c7e8f6f946db2497a09 (diff)
Add the ability to replace the source data file in Item_Model::save().
Refactor the rotate code in Quick_Controller to replace the data file, and then have gallery_event::item_updated_data_file() pick up after the change is saved, rebuild the image and handle album covers. This is much more portable than before and it will allow any mechanism (eg: REST) to replace the source image.
Diffstat (limited to 'modules/gallery/controllers/quick.php')
-rw-r--r--modules/gallery/controllers/quick.php22
1 files changed, 4 insertions, 18 deletions
diff --git a/modules/gallery/controllers/quick.php b/modules/gallery/controllers/quick.php
index fee601d9..c34209da 100644
--- a/modules/gallery/controllers/quick.php
+++ b/modules/gallery/controllers/quick.php
@@ -36,25 +36,11 @@ class Quick_Controller extends Controller {
}
if ($degrees) {
- gallery_graphics::rotate($item->file_path(), $item->file_path(),
- array("degrees" => $degrees));
-
- list($item->width, $item->height) = getimagesize($item->file_path());
- $item->resize_dirty= 1;
- $item->thumb_dirty= 1;
+ $tmpfile = tempnam(TMPPATH, "rotate");
+ gallery_graphics::rotate($item->file_path(), $tmpfile, array("degrees" => $degrees));
+ $item->set_data_file($tmpfile);
$item->save();
-
- graphics::generate($item);
-
- // @todo: this is an inadequate way to regenerate album cover thumbnails after rotation.
- foreach (ORM::factory("item")
- ->where("album_cover_item_id", "=", $item->id)
- ->find_all() as $target) {
- copy($item->thumb_path(), $target->thumb_path());
- $target->thumb_width = $item->thumb_width;
- $target->thumb_height = $item->thumb_height;
- $target->save();
- }
+ unlink($tmpfile);
}
if (Input::instance()->get("page_type") == "collection") {