CodeIgniter Image Manipulation Class: How to make

2019-09-04 08:20发布

问题:

I use CodeIgniter Image Manipulation Class to make a Thumbnail of my images.

so the problem is: the property thumb_marker job is inserting '_thumb' just before the file extension, so mypic.jpg would become mypic_thumb.jpg

but what I want is the opposite I need my file name be: thumb_mypic.jpg

回答1:

Extend the Image library.

class My_Image_lib extends Image_lib {

    public function initialize() {
        // copy the initialize method content here.
    }
}

Now, look for this line in initialize():

$this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext;

Change it to. Notice the $this->thumb_marker and $filename change:

$this->full_dst_path = $this->dest_folder.$this->thumb_marker.$filename.$file_ext;

Last you should set My_Image_lib->thumb_marker = 'thumb_';



回答2:

Edit this file \system\libraries\Image_lib.php

replace (~line 595)

$this->full_dst_path = $this->dest_folder.$filename.$this->thumb_marker.$file_ext;
on
$this->full_dst_path = $this->dest_folder.$this->thumb_marker.$filename.$file_ext;


标签: codeigniter