Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Added support to set the Minimum Width and Minimum Height of an image in the File Uploading Library #636

Closed
wants to merge 5 commits into
from
@@ -35,7 +35,7 @@
$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 exceedes the maximum height or width.";
+$lang['upload_invalid_dimensions'] = "The image you are attempting to upload does not meet 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.";
@@ -41,6 +41,8 @@ class CI_Upload {
public $max_size = 0;
public $max_width = 0;
public $max_height = 0;
+ public $min_width = 0;
+ public $min_height = 0;
public $max_filename = 0;
public $max_filename_increment = 100;
public $allowed_types = "";
@@ -96,6 +98,8 @@ public function initialize($config = array())
'max_size' => 0,
'max_width' => 0,
'max_height' => 0,
+ 'min_width' => 0,
+ 'min_height' => 0,
'max_filename' => 0,
'max_filename_increment' => 100,
'allowed_types' => "",
@@ -489,6 +493,32 @@ public function set_max_height($n)
$this->max_height = ((int) $n < 0) ? 0: (int) $n;
}
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Minimum Image Width
+ *
+ * @param integer
+ * @return void
+ */
+ public function set_min_width($n)
+ {
+ $this->min_width = ((int) $n < 0) ? 0: (int) $n;
+ }
+
+ // --------------------------------------------------------------------
+
+ /**
+ * Set Minimum Image Height
+ *
+ * @param integer
+ * @return void
+ */
+ public function set_min_height($n)
+ {
+ $this->min_height = ((int) $n < 0) ? 0: (int) $n;
+ }
+
// --------------------------------------------------------------------
/**
@@ -695,6 +725,16 @@ public function is_allowed_dimensions()
return FALSE;
}
+ if ($this->min_width > 0 AND $D['0'] < $this->min_width)
+ {
+ return FALSE;
+ }
+
+ if ($this->min_height > 0 AND $D['1'] < $this->min_height)
+ {
+ return FALSE;
+ }
+
return TRUE;
}
@@ -1086,4 +1126,4 @@ protected function _file_mime_type($file)
// END Upload Class
/* End of file Upload.php */
-/* Location: ./system/libraries/Upload.php */
+/* Location: ./system/libraries/Upload.php */
@@ -101,6 +101,8 @@ Release Date: Not Released
- Libraries
+ - Added support to set the Minimum Width and Minimum Height of an
+ image in the :doc:`File Uploading Library <libraries/file_uploading>`.
- Changed $this->cart->insert() in the :doc:`Cart
Library <libraries/cart>` to return the Row ID if a single
item was inserted successfully.
@@ -207,6 +207,10 @@ Preference Default Value Options Descripti
limit.
**max_height** 0 None The maximum height (in pixels) that the file can be. Set to zero for no
limit.
+**min_width** 0 None The minimum width (in pixels) that the file can be. Set to zero for no
+ limit.
+**min_height** 0 None The minimum height (in pixels) that the file can be. Set to zero for no
+ limit.
**max_filename** 0 None The maximum length that a file name can be. Set to zero for no limit.
**max_filename_increment** 100 None When overwrite is set to FALSE, use this to set the maximum filename
increment for CodeIgniter to append to the filename.