I have problem with image class in CI?
This is example
On controller:
$this->load->library( array('image_lib') );
On view i have this:
foreach($results as $row)
{
$config['image_library'] = 'gd2';
$config['source_image'] = '/img/proizvodi/'.$row->proizvodid.'.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$this->load->library('image_lib', $config);
$this->image_lib->resize();
}
But i got no error, and thumb image is not created? I dont know where is mistake?
You shouldn't load image_lib in foreach. Try to use code below
$this->load->library('image_lib');
foreach($results as $row) {
$config['image_library'] = 'gd2';
$config['source_image'] = '/img/proizvodi/'.$row->proizvodid.'.jpg';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
$this->image_lib->clear();
$this->image_lib->initialize($config);
$this->image_lib->resize();
}
If it wont work - check the upload folder permissions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With