From 8a2c7283a9d5dc5a63192addf380de867a1ced6a Mon Sep 17 00:00:00 2001 From: shish Date: Thu, 12 Jul 2007 08:59:23 +0000 Subject: [PATCH] resolution limiter git-svn-id: file:///home/shish/svn/shimmie2/trunk@273 7f39781d-f577-437e-ae19-be835c7a54ca --- contrib/res_limit/main.php | 47 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 contrib/res_limit/main.php diff --git a/contrib/res_limit/main.php b/contrib/res_limit/main.php new file mode 100644 index 00000000..2ae9b65b --- /dev/null +++ b/contrib/res_limit/main.php @@ -0,0 +1,47 @@ + + * Link: http://trac.shishnet.org/shimmie2/ + * License: GPLv2 + * Description: Allows the admin to set min / max image dimentions + */ +class ResolutionLimit extends Extension { + public function receive_event($event) { + if(is_a($event, 'UploadingImageEvent')) { + global $config; + $min_w = $config->get_int("upload_min_width", -1); + $min_h = $config->get_int("upload_min_height", -1); + $max_w = $config->get_int("upload_max_width", -1); + $max_h = $config->get_int("upload_max_height", -1); + + $image = $event->image; + + if($min_w > 0 && $image->width < $min_w) $event->veto("Image too small"); + if($min_h > 0 && $image->height < $min_w) $event->veto("Image too small"); + if($max_w > 0 && $image->width > $min_w) $event->veto("Image too large"); + if($max_h > 0 && $image->height > $min_w) $event->veto("Image too large"); + } + if(is_a($event, 'SetupBuildingEvent')) { + $sb = new SetupBlock("Resolution Limits"); + + $sb->add_label("Min "); + $sb->add_int_option("upload_min_width"); + $sb->add_label(" x "); + $sb->add_int_option("upload_min_height"); + $sb->add_label(" px"); + + $sb->add_label("
Max "); + $sb->add_int_option("upload_max_width"); + $sb->add_label(" x "); + $sb->add_int_option("upload_max_height"); + $sb->add_label(" px"); + + $sb->add_label("
(-1 for no limit)"); + + $event->panel->add_block($sb); + } + } +} +add_event_listener(new ResolutionLimit(), 40); // early, to veto UIE +?>