hey guys i have this problem, and i was spending 4-5 hours looking for a solution
here is my code
$config = array(
'upload_path' => './uploads/menus',
'allowed_types' => 'gif|jpg|jpeg|png',
'max_size' => '15000'
);
$this->upload->initialize($config);
if ($this->upload->do_upload('image'))
{
$image_data = $this->upload->data();
$thumbnail = 'thumb_' . $image_data['file_name'];
$thumb['image_library'] = 'gd2';
$thumb['source_image'] = $image_data['full_path'];
$thumb['create_thumb'] = TRUE;
$thumb['thumb_marker'] = '';
$thumb['new_image'] = $image_data['file_path'] . 'thumbs/' . $thumbnail;
$thumb['maintain_ratio'] = TRUE;
$thumb['width'] = 90;
$thumb['height'] = 90;
$this->load->library('image_lib', $thumb);
if($this->image_lib->resize())
{
$img_details = array(
'menu_id' => $this->db->insert_id(),
'full_path' => $image_data['full_path'],
'image_name' => $image_data['file_name'],
'thumb_path' => $thumb['new_image'],
'thumb_name' => $thumbnail,
);
$upload = $this->db->insert('menus_images', $img_details);
return $upload;
}
}
I’m using PyroCMS, and i’m developing a module in which i need to upload images. So far so good, my problem is this:
The image gets uploaded, the resize check is passing with no problem, is inserting the correct data in db, but in “thumbs” folder is NOT creating any thumb whatsoever.
If you have any suggestions please give me some help.
Thank you!
You can use Stream APi to develop your module. By the way I use PyroCMS and I’ve just finished a new module and I use codeigniter lib to create thumb with no problem.
You code semms correct, the only thing that I can suggest you is to separate the loading of the image_lib and its initialization in this way:
In this way you shouldn’t have any problem.
If it doesn’t work try to separate the main image and the thumb, you can create the first image and then the thumb with two separata function.