Welcome Guest, Not a member yet? Register   Sign In
image-lib new filename
#1

[eluser]jzmwebdevelopement[/eluser]
Hello,

I have my image resizer and uploder working fine but I need to pass the thumbnail filename "originalfile_thumb.png" into the database, what stores this?

Jess
#2

[eluser]R_Nelson[/eluser]
If im reading what your asking for correctly your looking for something like this
Code:
function do_upload() {
        
        $config = array(
            'allowed_types' => 'jpg|jpeg|gif|png',
            'upload_path' => $this->gallery_path,
            'max_size' => 2000
        );
        
        $this->load->library('upload', $config);
        $this->upload->do_upload();
        $image_data = $this->upload->data();
        
        $config = array(
            'source_image' => $image_data['full_path'],
            'new_image' => $this->gallery_path . '/thumbs',
            'maintain_ration' => true,
            'width' => 150,
            'height' => 100
        );
        
        $this->load->library('image_lib', $config);
        $this->image_lib->resize();
        
    }
#3

[eluser]jzmwebdevelopement[/eluser]
I have the following controller but I need to pass the new thumbnail name into my database. I have tried:

Code:
'thumbpath' =>$this->upload->file_name.'_thumb'

This saves the name as orginalfilename.png_thumb

I have also tried:

Quote: 'thumbpath' =>$this->upload->file_name'

This saves the original file name.

What I am trying to do is save the new thumbnail file name witch is orginalfilename_thumb.png


Code:
if($this->form_validation->run() === TRUE) {

    //Set File Settings
    $config['upload_path'] = 'includes/uploads/gallery/';
    $config['allowed_types'] = 'jpg|png';
    $config['max_size'] = '100';
    $config['max_width'] = '1024';
    $config['max_height'] = '768';

    $this->load->library('upload', $config);
    if(!$this->upload->do_upload()) {
    
    $error = array('imageError' => $this->upload->display_errors());
    $this->load->view('admintemplate', $data);
    }
    else{
    $data = array('upload_data' => $this->upload->data());
    $config['image_library'] = 'GD2';
    $config['source_image'] = $this->upload->upload_path.$this->upload->file_name;
    $config['new_image'] = 'includes/uploads/gallery/thumbs/';
    $config['create_thumb'] = 'TRUE';
    $config['thumb_marker'] ='_thumb';
    $config['maintain_ratio'] = 'FALSE';
    $config['width'] = '200';
    $config['height'] = '150';
    
    $this->load->library('image_lib', $config);
    $this->image_lib->resize();
    }
    
    $file_info = $this->upload->data();
    
    $data = array(  
        'description' => $this->input->post('description', TRUE),
        'fullpath' => $file_info['file_name'],
    'thumbpath' =>$this->upload->file_name.'_thumb'
        );
    $this->image_model->addImage($data);
    
    $this->data['success'] = 'Thank You, Your Image Has Been Uploaded';
    }
}
#4

[eluser]R_Nelson[/eluser]
you need to use raw_name not file_name

raw_name The file name without the extension
#5

[eluser]jzmwebdevelopement[/eluser]
Thanks,

Are you able to give me an example of how to do this as I do not see this in the user_guide. How would I add the file ext to the raw_name?
#6

[eluser]R_Nelson[/eluser]
Code:
'thumbpath' =>$this->upload->raw_name.'_thumb'.file_ext

that should work not sure if you need the file_ext at the end.

i found this in the file upload class near the bottom of the page!

http://ellislab.com/codeigniter/user-gui...ading.html
#7

[eluser]jzmwebdevelopement[/eluser]
Thank you - I was looking in the image manipulation class. I have tried the above but its giving me _thumbfile_ext
#8

[eluser]R_Nelson[/eluser]
i would suggest reading the URL i have you it should work not sure if you need to add a path to the file or what but i know it can be done in CI if not you can use normal php and find the dot and insert the _thumb before it! you would have to lo0k it up but i believe its the substr command or something i forget!




Theme © iAndrew 2016 - Forum software by © MyBB