[eluser]SPeed_FANat1c[/eluser]
Hi, actually I noticed that my code is not working how I want - it creates thumnail, rezises the image to be lees than 700 widht, but it creates a copy with ending _thumb and leaves the original. But I want original to be replaced.
Now what I am trying to do:
I don't create a thumbnail, but instead first rezize the image and then create a thumbnail:
Code:
function image_resize_for_gallery($album_folder, $image_name)
{
$config['image_library'] = 'gd2';
$config['source_image'] = './uploads/gallery/'.$album_folder.'/'.$image_name;
$config['maintain_ratio'] = TRUE;
$config['width'] = 700;
$config['height'] = 700;
echo ($config['source_image']);
$this->load->library('image_lib');
$this->image_lib->initialize($config);
if ( ! $this->image_lib->resize())
{
$this->image_lib->clear();
return $this->image_lib->display_errors();
}
else
{
$this->image_lib->clear();
$this->gallery_thumb($album_folder,$image_name);
return 'ok';
}
}
Here you see I call
Code:
$this->gallery_thumb($album_folder,$image_name);
after resizing and clearing library. But the problem is - it does not add the ending _thumb to thumbnail file now.
Thumbnail creation function:
Code:
function gallery_thumb($album_folder,$image_name)
{
$config['image_library'] = 'gd2';
$config['source_image'] = './uploads/gallery/'.$album_folder.'/'.$image_name;
$config['new_image'] = './uploads/gallery/'.$album_folder.'/thumbs';
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 50;
//$this->load->library('image_lib',$config);
$this->image_lib->initialize($config);
echo $config['create_thumb'];
if ( ! $this->image_lib->resize())
{
/// $this->image_lib->display_errors();
log_message('error', $this->image_lib->display_errors());
//echo $this->image_lib->display_errors(); //test
$this->image_lib->clear();
return FALSE;
}
else
{
$this->image_lib->clear();
return TRUE;
}
}
As you can see there is such line to add _thumb:
$config['create_thumb'] = TRUE;
But it seems that library just ignores it. I don't understand why is that?
Edit:
Found a one thing:
in the library there is such code:
Code:
if ($this->create_thumb === FALSE OR $this->thumb_marker == '')
{
$this->thumb_marker = '';
}
And I checked that $this->thumb_marker has value '' so thats why it does not add the ending. Now the question why it has such value? I didn't set the marker in my gallerry thumb function and I didn't set it anywhere.
After That I just added line
$config['thumb_marker'] = '_thumb';
in gallery_thumb function and then it creates good filename. But how did it dissapier..