I have 5 image upload fields. I am trying to resize all 5 images, at the moment when the script runs it will only resize one of the 5. Heres the code
function on_after_post($values)
{
$CI =& get_instance();
$CI->load->library('image_lib');
// create the thumbnail if an image is uploaded
if (!empty($CI->upload))
{
$data = $CI->upload->data();
if (!empty($data['full_path']))
{
$thumb_img300 = assets_server_path('prod/300/'.$this->thumb_name($data['file_name']), 'images');
// create thumb 300 height
$config = array();
$config['source_image'] = $data['full_path'];
$config['create_thumb'] = FALSE;
$config['new_image'] = $thumb_img300;
$config['width'] = 200;
$config['height'] = 300;
$config['master_dim'] = 'auto';
$config['maintain_ratio'] = TRUE;
//$CI->image_lib->clear();
$CI->image_lib->initialize($config);
if(!$this->image_lib->resize()) echo $this->image_lib->display_errors();
}
}
return $values;
}
Comments
upload->data() gets you an array of information for a file, from the docs: This is a helper function that returns an array containing all of the data related to the file you uploaded.
So it's per file, hence only saving one.