thumbnail codeigniter

Asked

Viewed 87 times

1

I built this class that makes a multiupload of images, creates the folders according to the id_year, and then generates the Thumbs of these images as per the foreach wheel. The problem is that the Thumbs are not being generated.

My class Thumb:

function _createThumbnail($filename,$path)
{        

    $config['image_library']    = "gd2";      

    $config['source_image']     = "{$path}/{$filename}";                

    $config['create_thumb']     = TRUE;      

    $config['maintain_ratio']   = TRUE;      

    $config['width'] = "80";      

    $config['height'] = "80";

    $this->load->library('image_lib',$config);
    //die(print_r($this->image_lib->resize()));
    if(!$this->image_lib->resize())

    {

        die(print_r($this->image_lib->display_errors()));

    }      
}

1 answer

0

Good afternoon. I would use it this way:

function _createThumbnail($filename,$path)
{        
    $this->load->library('image_lib');
    $config['image_library']    = "gd2";      

    $config['source_image']     = "{$path}/{$filename}";                

    $config['create_thumb']     = TRUE;      

    $config['maintain_ratio']   = TRUE;      

    $config['width'] = "80";      

    $config['height'] = "80";

    $this->image_lib->clear();
    $this->image_lib->initialize($config);

    //die(print_r($this->image_lib->resize()));
    if(!$this->image_lib->resize())

    {

        die(print_r($this->image_lib->display_errors()));

    }      
}

I’ve had problems on servers where first I should clean the lib configuration and then configure it again.

I hope I’ve helped.

Oss

Browser other questions tagged

You are not signed in. Login or sign up in order to post.