From 52f1c4b8c6a3a4043fcca3901a659b140b77f9d9 Mon Sep 17 00:00:00 2001 From: Bharat Mediratta Date: Tue, 27 Jul 2010 10:49:47 -0700 Subject: [PATCH] Don't invoke a graphics toolkit when setting the album cover from a clean thumbnail; we can just copy it over. Should be a decent perf improvement in many cases. Fixes ticket #1255. --- modules/gallery/helpers/item.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/modules/gallery/helpers/item.php b/modules/gallery/helpers/item.php index 8fea49cc67..092904a5cc 100644 --- a/modules/gallery/helpers/item.php +++ b/modules/gallery/helpers/item.php @@ -105,9 +105,15 @@ static function make_album_cover($item) { model_cache::clear(); $parent->album_cover_item_id = $item->is_album() ? $item->album_cover_item_id : $item->id; - $parent->thumb_dirty = 1; + if ($item->thumb_dirty) { + $parent->thumb_dirty = 1; + graphics::generate($parent); + } else { + copy($item->thumb_path(), $parent->thumb_path()); + $parent->thumb_width = $item->thumb_width; + $parent->thumb_height = $item->thumb_height; + } $parent->save(); - graphics::generate($parent); $grand_parent = $parent->parent(); if ($grand_parent && access::can("edit", $grand_parent) && $grand_parent->album_cover_item_id == null) {