Welcome Guest, Not a member yet? Register   Sign In
Simple Resize Model Setup

(This post was last modified: 02-01-2015, 05:48 AM by wolfgang1983.)

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!

Theme © iAndrew 2016 - Forum software by © MyBB