Welcome Guest, Not a member yet? Register   Sign In
How can i load a library file in a helper file?
#7

[eluser]dcunited08[/eluser]
I would just call the library directly and add a config file for it to hold the default values, that seems why you are putting it in a function. Another option, subclass it as MY_image_lib and create a static method that does what this does.
Code:
class MY_Image_lib extends CI_Image_lib{

var $image_library = 'gd2';
var $create_thumb = TRUE;
var $maintain_ratio = TRUE;
var $width = 80;
var $height = 60;

static function resize_image( $file_path ) {
    
    $image['source_image']    = $file_path;
    $image_lib = new MY_Image_lib($image);

    if( $image_lib->resize() ) {

        $image_lib->clear();
        return true;
    }

    return false;
}
}

That way you can call it:
Code:
$return = MY_Image_lib::resize_image($file);


Messages In This Thread
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 06:48 AM
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 06:57 AM
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 06:59 AM
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 07:10 AM
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 07:19 AM
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 07:19 AM
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 07:38 AM
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 07:54 AM
How can i load a library file in a helper file? - by El Forum - 11-07-2008, 08:45 AM



Theme © iAndrew 2016 - Forum software by © MyBB