• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Simple Resize Model Setup

Another quick little code came up with if any one wants to use.

If you would like to resize images with out having to put a resize function in each controller each time, you could use this model and then in your controller

All you would have to enter is $this->image_resize->resize('1.jpg', 100, 100); the first one is image name, the second part is image width size and third is image height. make sure load model of course in controller.

PHP Code:

class Image_resize extends CI_Model {
    public function 
resize($filename$width$height) {
$config['image_library'] = 'gd2';
$config['source_image'] = FCPATH 'upload'.'/'.$filename;
$config['create_thumb'] = FALSE;
$config['maintain_ratio'] = FALSE;
$config['width'] = $width;
$config['height'] = $height;
$config['new_image'] = FCPATH 'image/cache'.'/'.$width.'x'.$height.'-'.$filename;



Attached Files
.php   image_resize.php (Size: 562 bytes / Downloads: 170)
There's only one rule - please don't tell anyone to go and read the manual.  Sometimes the manual just SUCKS!

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.