• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do I make multiple thumbails for the same image with image_lib?

#16
[eluser]SitesByJoe[/eluser]
I don't know of any function to "not" use the original image, but it'd be easy enough to add something like this to your code to remove the original:

Code:
unlink($file_data['your_file_path']);

Truthfully, I don't even use the upload component (a habit I started in CI 1.4!) as I had path trouble and instead did this, well this is a snippet anyway:

Code:
if ($file['name'] > '')
{
        $uploadDir = 'uploads/my_folder/';
        $filename = $id . '-' . $file['name'];
        $path = $uploadDir . $filename;        
        
        // overwrite any pre-existing files                
        unlink($path);
        
        // if we can now save our new file    
        if (move_uploaded_file($_FILES['userfile']['tmp_name'], $path)) // MY NON-CI UPLOAD
        {        
                $data = array(
                        'portfolio_id' => $id,
                        'image_path' => $path,
                        'caption' => $this->input->post('caption'),
                        'sort_order' => 99
                );
                
                // if so save the path
                $this->load->model('Photos_model');
                $this->Photos_model->insert_photo($data);

                // make a thumbnail of our photo
                $this->load->library('image_lib');                        
                $config['image_library'] = 'GD2';
                $config['source_image'] = $path;
                $config['create_thumb'] = TRUE;
                $config['thumb_marker'] = '_tmb';
                $config['quality'] = '100%';
                $config['width'] = 100;
                $config['height'] = 100;                
                $this->image_lib->initialize($config);
                $this->image_lib->resize();                
        }    
}


Messages In This Thread
How do I make multiple thumbails for the same image with image_lib? - by El Forum - 05-17-2010, 06:50 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2021 MyBB Group.