diff --git a/contrib/regen_thumb/main.php b/contrib/regen_thumb/main.php index 23aac9a6..cf3e2eb6 100644 --- a/contrib/regen_thumb/main.php +++ b/contrib/regen_thumb/main.php @@ -18,7 +18,7 @@ class RegenThumb extends SimpleExtension { if($event->page_matches("regen_thumb") && $user->is_admin() && isset($_POST['image_id'])) { $image = Image::by_id(int_escape($_POST['image_id'])); - send_event(new ThumbnailGenerationEvent($image->hash, $image->ext)); + send_event(new ThumbnailGenerationEvent($image->hash, $image->ext, true)); $this->theme->display_results($page, $image); } } diff --git a/core/extension.class.php b/core/extension.class.php index d9cd0a18..ccd287d2 100644 --- a/core/extension.class.php +++ b/core/extension.class.php @@ -194,7 +194,12 @@ abstract class DataHandlerExtension implements Extension { } if(($event instanceof ThumbnailGenerationEvent) && $this->supported_ext($event->type)) { - $this->create_thumb($event->hash); + if (method_exists($this, 'create_thumb_force') && $event->force == true) { + $this->create_thumb_force($event->hash); + } + else { + $this->create_thumb($event->hash); + } } if(($event instanceof DisplayingImageEvent) && $this->supported_ext($event->image->ext)) { diff --git a/ext/handle_pixel/main.php b/ext/handle_pixel/main.php index 4cea671f..2e4cd734 100644 --- a/ext/handle_pixel/main.php +++ b/ext/handle_pixel/main.php @@ -48,6 +48,14 @@ class PixelFileHandler extends DataHandlerExtension { } protected function create_thumb($hash) { + $outname = warehouse_path("thumbs", $hash); + if(file_exists($outname)) { + return true; + } + return $this->create_thumb_force($hash); + } + + protected function create_thumb_force($hash) { $inname = warehouse_path("images", $hash); $outname = warehouse_path("thumbs", $hash); global $config; diff --git a/ext/image/main.php b/ext/image/main.php index a42c7916..d4daf7a0 100644 --- a/ext/image/main.php +++ b/ext/image/main.php @@ -89,17 +89,18 @@ class ImageReplaceException extends SCoreException { * Request a thumbnail be made for an image object. */ class ThumbnailGenerationEvent extends Event { - var $hash, $type; - + var $hash, $type, $force; + /** * Request a thumbnail be made for an image object * * @param $hash The unique hash of the image * @param $type The type of the image */ - public function ThumbnailGenerationEvent($hash, $type) { + public function ThumbnailGenerationEvent($hash, $type, $force=false) { $this->hash = $hash; $this->type = $type; + $this->force = $force; } }