[eluser]Sinclair[/eluser]
Hi,
Here is the extension to the Upload class. But it is not working...
Code:
<?PHP
class MY_Upload extends CI_Upload {
var $min_width = 0;
var $min_height = 0;
/**
* Initialize preferences
*
* @access public
* @param array
* @return void
*/
function initialize($config = array())
{
$defaults = array(
'max_size' => 0,
'max_width' => 0,
'max_height' => 0,
'max_filename' => 0,
'min_width' => 0,
'min_height' => 0,
'allowed_types' => "",
'file_temp' => "",
'file_name' => "",
'orig_name' => "",
'file_type' => "",
'file_size' => "",
'file_ext' => "",
'upload_path' => "",
'overwrite' => FALSE,
'encrypt_name' => FALSE,
'is_image' => FALSE,
'image_width' => '',
'image_height' => '',
'image_type' => '',
'image_size_str' => '',
'error_msg' => array(),
'mimes' => array(),
'remove_spaces' => TRUE,
'xss_clean' => FALSE,
'temp_prefix' => "temp_file_"
);
foreach ($defaults as $key => $val)
{
if (isset($config[$key]))
{
$method = 'set_'.$key;
if (method_exists($this, $method))
{
$this->$method($config[$key]);
}
else
{
$this->$key = $config[$key];
}
}
else
{
$this->$key = $val;
}
}
}
/**
* Set Minimum Image Height
*
* @access public
* @param integer
* @return void
*/
function set_min_height($n)
{
$this->min_height = ((int) $n < 0) ? 0: (int) $n;
}
/**
* Set Minimum Image Width
*
* @access public
* @param integer
* @return void
*/
function set_min_width($n)
{
$this->min_width = ((int) $n < 0) ? 0: (int) $n;
}
/**
* Verify that the image is within the allowed width/height
*
* @access public
* @return bool
*/
function is_allowed_dimensions()
{
if ( ! $this->is_image())
{
return TRUE;
}
if (function_exists('getimagesize'))
{
$D = @getimagesize($this->file_temp);
if ($this->max_width > 0 AND $D['0'] > $this->max_width)
{
return FALSE;
}
if ($this->max_height > 0 AND $D['1'] > $this->max_height)
{
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;
}
return TRUE;
}
}
In the config.php I have added:
Code:
$config['min_width'] = '300';
$config['min_height'] = '300';
What I need to do more to get this extension working?
Best Regards,