From 05aa2d653a76b086a909739b2c9386289aa2e0fb Mon Sep 17 00:00:00 2001 From: Andrey Andreev Date: Mon, 3 Dec 2012 16:06:55 +0200 Subject: Add min_width and min_height options to the Upload class (manually implementing outdated PR #636) --- system/libraries/Upload.php | 52 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'system/libraries') diff --git a/system/libraries/Upload.php b/system/libraries/Upload.php index 5d163fb77..4f65c9eb1 100644 --- a/system/libraries/Upload.php +++ b/system/libraries/Upload.php @@ -58,6 +58,20 @@ class CI_Upload { */ public $max_height = 0; + /** + * Minimum image width + * + * @var int + */ + public $min_width = 0; + + /** + * Minimum image height + * + * @var int + */ + public $min_height = 0; + /** * Maximum filename length * @@ -269,6 +283,8 @@ class CI_Upload { 'max_size' => 0, 'max_width' => 0, 'max_height' => 0, + 'min_width' => 0, + 'min_height' => 0, 'max_filename' => 0, 'max_filename_increment' => 100, 'allowed_types' => '', @@ -673,6 +689,32 @@ class CI_Upload { // -------------------------------------------------------------------- + /** + * Set minimum image width + * + * @param int $n + * @return void + */ + public function set_min_width($n) + { + $this->min_width = ((int) $n < 0) ? 0 : (int) $n; + } + + // -------------------------------------------------------------------- + + /** + * Set minimum image height + * + * @param int $n + * @return void + */ + public function set_min_height($n) + { + $this->min_height = ((int) $n < 0) ? 0 : (int) $n; + } + + // -------------------------------------------------------------------- + /** * Set Allowed File Types * @@ -859,6 +901,16 @@ class CI_Upload { { return FALSE; } + + if ($this->min_width > 0 && $D[0] < $this->min_width) + { + return FALSE; + } + + if ($this->min_height > 0 && $D[1] < $this->min_height) + { + return FALSE; + } } return TRUE; -- cgit v1.2.3-24-g4f1b