[eluser]xwero[/eluser]
AFAIK when a library is loaded it checks if the settings are added to the load method or if a config file is found.
Code:
function _ci_init_class($class, $prefix = '', $config = FALSE, $object_name = NULL)
{
// Is there an associated config file for this class?
if ($config === NULL)
{
// We test for both uppercase and lowercase, for servers that
// are case-sensitive with regard to file names
if (file_exists(APPPATH.'config/'.strtolower($class).EXT))
{
include_once(APPPATH.'config/'.strtolower($class).EXT);
}
else
{
if (file_exists(APPPATH.'config/'.ucfirst(strtolower($class)).EXT))
{
include_once(APPPATH.'config/'.ucfirst(strtolower($class)).EXT);
}
}
}
// ...
A quick workaround would be to load a custom config file for the class, or other settings in the case of the example below
Code:
<?php
$config['image_lib'] = array('resize'=>array(
'image_library' => 'gd2',
'create_thumb' => TRUE,
'maintain_ratio' => TRUE,
'width' = 75,
'height' = 50,
)
);
And in your controller you do
Code:
$this->load->config('settings');
$settings = $this->config->item('image_lib');
$resize = array();
$resize['source_image'] = $source_image;
$this->load->library('image_lib', array_merge($settings['resize'],$resize));
$this->image_lib->resize();
A permanent solution could be to remove the null check, change the config parameter to settings and add following code after the inclusion
Code:
if(is_array($settings) && is_array($config))
{
$config = array_merge($config,$settings);
}
Then you can have a config file and in the controller do
Code:
$resize = array();
$resize['source_image'] = $source_image;
$this->load->library('image_lib', $resize);
But then you have a problem with the different settings in the image_lib class. What if you want a different image processing library for resizing and rotation?