Welcome Guest, Not a member yet? Register   Sign In
Timthumb for CodeIgniter
#2

[eluser]pickupman[/eluser]
You can use a simple image controller to do this with the [url="http://ellislab.com/codeigniter/user-guide/libraries/image_lib.html"]Image Library[/url]. I have done something like this:
Code:
class Image extends CI_Controller
{
  public function index($width = 100, $height = 100, $image_path)
  {
     $config['image_library'] = 'gd2';
     $config['source_image'] = $image_ath;
     $config['dynamic_output'] = TRUE;
     $config['maintain_ratio'] = TRUE;
     $config['width'] = $width;
     $config['height'] = $height;

     $this->load->library('image_lib', $config);
     echo $this->image_lib->resize();
  }
}

//Call from view
<img src="image/100/100/my-image.jpg" alt="" />

Using the image class is pretty simple to write a resize or crop image handler.


Messages In This Thread
Timthumb for CodeIgniter - by El Forum - 04-01-2012, 04:17 AM
Timthumb for CodeIgniter - by El Forum - 04-01-2012, 08:46 PM
Timthumb for CodeIgniter - by El Forum - 04-02-2012, 02:56 AM
Timthumb for CodeIgniter - by El Forum - 04-02-2012, 02:33 PM



Theme © iAndrew 2016 - Forum software by © MyBB