Your Ad Here

Home » CodeIgniter »

1

In this post i would like to explain about how to create thumbnail images in codeigniter framework. In the following function will give the clear understand about the code.

Create Thumbnail Function

1
2
3
4
5
6
7
8
9
10
11
function _createThumbnail($fileName) {
$config['image_library'] = 'gd2';
$config['source_image'] = 'uploads/' . $fileName;
$config['create_thumb'] = TRUE;
$config['maintain_ratio'] = TRUE;
$config['width'] = 75;
$config['height'] = 75;

$this->load->library('image_lib', $config);
if(!$this->image_lib->resize()) echo $this->image_lib->display_errors();
}

Call the above function like :

1
$this->_createThumbnail($fInfo['file_name']);

After creation of thumbnail clear the caches.

1
$this->image_lib->clear();

Hope that it will be useful.


You may like these posts

    What is CodeIgniter,how to install in local system?How to create database connection using codegniter?How to write SEO friendly urls in CodeIgniterHow to configure the baseurl in CodeIgniter

 

1 Comment

Leave a Reply