⚠ In case you've missed it, we have migrated to our new website, with a brand new forum. For more details about the migration you can read our blog post for website migration. This is an archived forum. ⚠

  •     

profile picture

Storing image file as original sized image and thumbnail image



zgames
  • profile picture
  • Member

Posted 19 February 2013 - 19:37 PM

Hello web developers :) I looked around the forums, but I couldn't find an answer to my problem. 

The function itself is working, no problems uploading image or resizing it if it's one image and one action at a time.

 

I'm using this example below:

 

function image_callback_after_upload($uploader_response,$field_info, $files_to_upload)
    {
    
        $this->load->library('image_moo');
     
        //Is only one file uploaded so it ok to use it with $uploader_response[0].
        $file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name; 
        $thumbnail = $field_info->upload_path.'/thumbnail/'.$uploader_response[0]->name;

        $this->image_moo->load($file_uploaded)->save($file_uploaded,true);
        $this->image_moo->load($thumbnail)->resize(220,80)->save($thumbnail,true);
     
        return true;
    }

 

and I have these setups in my main crud function:

$this->config->set_item('grocery_crud_file_upload_allow_file_types', 'gif|jpeg|jpg|png');
$crud->set_field_upload('file_url','assets/uploads/files');
$crud->callback_after_upload(array($this,'image_callback_after_upload'));

what I want to do is to create a thumbnail which will be stored to assets/uploads/files/thumbnail/image_name 

and original size picture to be stored in assets/uploads/files/image_name , however for some reason my thumbnail is not created. I also have set permission to my thumbnail, files and uploads folders to 777. note I did not set any permission for asset folder but I think it's on 777 permission as well.

 

when I remove one action, for example 

$file_uploaded = $field_info->upload_path.'/'.$uploader_response[0]->name;
$this->image_moo->load($file_uploaded)->save($file_uploaded,true);

than a thumbnail is created but for some reason it is ignoring the path root which would be assets/uploads/files/thumbnail/image_name my thumbnail is stored than in the main upload folder 

assets/uploads/files/image_name 

 

Could someone tell me first of all

 

why is this path being ignored

 $thumbnail = $field_info->upload_path.'/thumbnail/'.$uploader_response[0]->name;

 

 
and why can't image_moo create two separate files 
 
thank you
 
 

zgames
  • profile picture
  • Member

Posted 19 February 2013 - 22:28 PM

i found the mistake 

 

changed from this

$this->image_moo->load($thumbnail)->resize(220,80)->save($thumbnail,true);


to
$this->image_moo->load($file_uploaded)->resize(220,80)->save($thumbnail,true);
 

problem solved


Donna111
  • profile picture
  • Member

Posted 15 October 2013 - 10:10 AM

Hi there

I found that to create image thumbnail using code is so difficult for me.Actually,i am not so good at computer,so i want to get an easier way to create image thumbnails.

I know there are many third party program for image .So is there any  powerful program?Thanks for any suggestion.


Robert
  • profile picture
  • Member

Posted 16 October 2013 - 06:05 AM

Donna111 depends on what you need .. if you only need to see a small thumbnail in the view and when you click it to see the full image in fancybox then you can simply use a small css change im using.

 

Go to assets\grocery_crud\themes\flexigrid\css\flexigrid.css look for .flexigrid a img (line 743 - i have modification to the css so it can be other line at you ) and simply add height:80px; after border: none; . I hope this can help you.