[eluser]SaminOz[/eluser]
Thanks for your reply Irfan - The issue was solved by not re-loading the library (class) and using $this->image_lib->initialize($config) to pass the new parameters.
FYI - your suggestion of passing the file info as parameters to the methods would not have been effective in the sense that the class properties already held the required info. This may not have been clear from the way I presented the code. I should have shown it something like this:
Code:
class someclass extends CI_controller {
public function show_images_for_this_id ($id = NULL)
{
//do various things here, then:
if ( ! $this->upload->do_upload())
{
$data['error'] = array('error' => $this->upload->display_errors());
}
else
{
$this->load->helper('file');
$data['error'] = $this->file_data = $this->upload->data();
$this->create_copy();
$this->create_thumb();
delete_files($this->file_data['file_path']);
//do some other stuff like load views
}
}
private function create_copy()
{
$config['image_library'] = 'gd2';
$config['source_image'] = $this->file_data['full_path'];
$config['new_image'] = './full_image/full_image_' .$this->some_obj->obj_id. '_XX'.$this->file_data['file_ext'];
$this->load->library('image_lib');
$this->image_lib->initialize($config);
if ( ! $this->image_lib->resize())
{
var_dump('1', $this->image_lib->display_errors());
}
}
private function create_thumb()
{
$this->image_lib->clear();
$config['image_library'] = 'gd2';
$config['source_image'] = $this->file_data['full_path'];
$config['new_image'] = './thumb_image/thumb_image_' .$this->some_obj->obj_id. '_12'.$this->file_data['file_ext'];
$config['maintain_ratio'] = TRUE;
$config['width'] = 168;
$config['height'] = 101;
$this->image_lib->initialize($config);
if ( ! $this->image_lib->resize())
{
var_dump('2', $this->image_lib->display_errors());
}
}
}