diff options
author | Bharat Mediratta <bharat@menalto.com> | 2009-02-08 10:18:09 +0000 |
---|---|---|
committer | Bharat Mediratta <bharat@menalto.com> | 2009-02-08 10:18:09 +0000 |
commit | 3a83c4e76fcfd3e9e62d95fe91222367527411e4 (patch) | |
tree | c0fe1e8a6c14c984eb8f79b4ead09b141fd22420 | |
parent | 442d9295c62903d2595abefb485bb9f869f3ce8e (diff) |
Properly implement changing the thumbnail and resized image sizes by
updating the graphics rules as appropriate.
-rw-r--r-- | core/controllers/admin_theme_details.php | 25 | ||||
-rw-r--r-- | core/helpers/graphics.php | 16 |
2 files changed, 38 insertions, 3 deletions
diff --git a/core/controllers/admin_theme_details.php b/core/controllers/admin_theme_details.php index 6ef28ef9..ecb359de 100644 --- a/core/controllers/admin_theme_details.php +++ b/core/controllers/admin_theme_details.php @@ -28,8 +28,29 @@ class Admin_Theme_Details_Controller extends Admin_Controller { $form = theme::get_edit_form_admin(); if ($form->validate()) { module::set_var("core", "page_size", $form->edit_theme->page_size->value); - module::set_var("core", "thumb_size", $form->edit_theme->thumb_size->value); - module::set_var("core", "resize_size", $form->edit_theme->resize_size->value); + + $thumb_size = $form->edit_theme->thumb_size->value; + $thumb_dirty = false; + if (module::get_var("core", "thumb_size") != $thumb_size) { + graphics::remove_rule("core", "thumb", "resize"); + graphics::add_rule( + "core", "thumb", "resize", + array("width" => $thumb_size, "height" => $thumb_size, "master" => Image::AUTO), + 100); + module::set_var("core", "thumb_size", $thumb_size); + } + + $resize_size = $form->edit_theme->resize_size->value; + $resize_dirty = false; + if (module::get_var("core", "resize_size") != $resize_size) { + graphics::remove_rule("core", "resize", "resize"); + graphics::add_rule( + "core", "resize", "resize", + array("width" => $resize_size, "height" => $resize_size, "master" => Image::AUTO), + 100); + module::set_var("core", "resize_size", $resize_size); + } + message::success(t("Updated theme details")); url::redirect("admin/theme_details"); } else { diff --git a/core/helpers/graphics.php b/core/helpers/graphics.php index f80d88f5..f708435b 100644 --- a/core/helpers/graphics.php +++ b/core/helpers/graphics.php @@ -48,7 +48,21 @@ class graphics_Core { $rule->args = serialize($args); $rule->save(); - self::mark_dirty(true, true); + self::mark_dirty($target == "thumb", $target == "resize"); + } + + /** + * Remove any matching graphics rules + * @param string $module_name the module that added the rule + * @param string $target the target for this operation ("thumb" or "resize") + * @param string $operation the name of the operation + */ + static function remove_rule($module_name, $target, $operation) { + ORM::factory("graphics_rule") + ->where("module_name", $module_name) + ->where("target", $target) + ->where("operation", $operation) + ->delete_all(); } /** |