You can create a new library for your project.
Your library classes should be placed within your application/libraries directory, as this is where CodeIgniter will look for them when they are initialized.
Be sure that:
- File names must be capitalized. For example: ImgPicker.php
- Class declarations must be capitalized. For example: class ImgPicker
- Class names and file names must match.
Your ImgPicker class file
Classes in general should have this basic prototype:
<?php defined('BASEPATH') OR exit('No direct script access allowed');
class ImgPicker {
// all stuff that your php library does
public function some_method()
{
. . .
}
}
Then from your controller (or model) you can load your library with $this->load->library('someclass'); and you can pass vars to the constructor dynamically like so:
$params = array('type' => 'large', 'color' => 'red');
$this->load->library('ImgPicker', $params);
You can find a lot of useful information how to create your own libraries (or convert existing php classes to CI libraries) at CI documentation.