summaryrefslogtreecommitdiffstats
path: root/system/libraries/Upload.php
diff options
context:
space:
mode:
authorAndrey Andreev <narf@bofh.bg>2012-12-03 15:06:55 +0100
committerAndrey Andreev <narf@bofh.bg>2012-12-03 15:06:55 +0100
commit05aa2d653a76b086a909739b2c9386289aa2e0fb (patch)
tree5738bbd52253fad8f602967b3f898ad57df5f2e2 /system/libraries/Upload.php
parent0259d1240d298beb71627da9c808c2f6a41e4656 (diff)
Add min_width and min_height options to the Upload class
(manually implementing outdated PR #636)
Diffstat (limited to 'system/libraries/Upload.php')
-rw-r--r--system/libraries/Upload.php52
1 files changed, 52 insertions, 0 deletions
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
@@ -59,6 +59,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
*
* @var int
@@ -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' => '',
@@ -674,6 +690,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
*
* @param string $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;