summaryrefslogtreecommitdiffstats
path: root/system
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
parent0259d1240d298beb71627da9c808c2f6a41e4656 (diff)
Add min_width and min_height options to the Upload class
(manually implementing outdated PR #636)
Diffstat (limited to 'system')
-rw-r--r--system/language/english/upload_lang.php2
-rw-r--r--system/libraries/Upload.php52
2 files changed, 53 insertions, 1 deletions
diff --git a/system/language/english/upload_lang.php b/system/language/english/upload_lang.php
index 88f9ac372..26a5c545c 100644
--- a/system/language/english/upload_lang.php
+++ b/system/language/english/upload_lang.php
@@ -36,7 +36,7 @@ $lang['upload_stopped_by_extension'] = 'The file upload was stopped by extension
$lang['upload_no_file_selected'] = 'You did not select a file to upload.';
$lang['upload_invalid_filetype'] = 'The filetype you are attempting to upload is not allowed.';
$lang['upload_invalid_filesize'] = 'The file you are attempting to upload is larger than the permitted size.';
-$lang['upload_invalid_dimensions'] = 'The image you are attempting to upload exceeds the maximum height or width.';
+$lang['upload_invalid_dimensions'] = 'The image you are attempting to upload doesn\'t fit into the allowed dimensions.';
$lang['upload_destination_error'] = 'A problem was encountered while attempting to move the uploaded file to the final destination.';
$lang['upload_no_filepath'] = 'The upload path does not appear to be valid.';
$lang['upload_no_file_types'] = 'You have not specified any allowed file types.';
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;