It looks like you're new here. If you want to get involved, click one of these buttons!
<?php
if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Createthumbs extends CI_Controller {
function __construct()
{
parent::__construct();
// load all the helpers we need
$this->load->helper('convert');
$this->load->helper('ajax');
$this->load->helper('cookie');
$this->load->helper('inflector');
$this->load->helper('text');
$this->load->library('image_lib');
}
}
A PHP Error was encountered
Severity: Notice
Message: Undefined property: Dennie::$image_lib
Filename: fuel/Loader.php
Line Number: 215
Comments
<?php $CI =& get_instance(); $CI->load->library('createthumbs') ?>
or
<?php $this->load->library('createthumbs') ; ?>
For example loading the library in the view works fine:
$this->load->library('image_lib');
$this->load->library('form');
I solved my problem by not extending the CI_Controller but by just making a class:
class Createthumb { public function __construct( $params = array() ) { $this->CI =& get_instance(); if (count($params) > 0) { $this->initialize($params); } $this->CI->load->library('image_lib'); } function initialize($config = array()) { foreach ($config as $key => $val) { if (isset($this->$key)) { $this->$key = $val; } } } function makethumb( $img, $width, $heigth ) { $fotonaam = basename($img); $fotonaam_no_extension = pathinfo($img, PATHINFO_FILENAME); $img_tumb_path = dirname($img) . '/thumbs/' . $fotonaam_no_extension . '_' . $width . '_' . $heigth . '.jpg' ; $img_source_path = $img . '/' . $fotonaam; // ChromePhp::log(MODULES_PATH); if (!file_exists($img_tumb_path)) { $config['image_library'] = 'gd2'; $config['source_image'] = $img_source_path; $config['width'] = $width; $config['height'] = $heigth; $config['new_image'] = $img_tumb_path; $this->CI->image_lib->initialize($config); if ( ! $this->CI->image_lib->resize()) { ChromePhp::log($this->CI->image_lib->display_errors()); } $this->CI->image_lib->clear(); } return dirname( $_SERVER['SCRIPT_NAME']) . '/' . $img_tumb_path; } }
Thanks for all the feedback again.
If anyone comes up with an idea I would still like to know what could be the problem.
Anyway, I tried it and had no errors with:
Createthumbs.php in /modules/my_module/libraries/
class Createthumbs extends CI_Controller { function __construct() { parent::__construct(); $this->load->helper('convert'); $this->load->helper('ajax'); $this->load->helper('cookie'); $this->load->helper('inflector'); $this->load->helper('text'); $this->load->library('image_lib'); echo 'loaded'; } }
In a view in the adv. module:
$this->load->module_library('my_module', 'createthumbs');
No errors, just see 'loaded' on the screen.