Codeigniter image resize? -
i have problem image class in ci?
this example
on controller:
$this->load->library( array('image_lib') );
on view have this:
foreach($results $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 got no error, , thumb image not created? dont know mistake?
you shouldn't load image_lib in foreach. try use code below
$this->load->library('image_lib'); foreach($results $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 wont work - check upload folder permissions.
Comments
Post a Comment