Hey! Keep up to date with the project through its beta and public launch by following @getsparks.

2,358 Installs

Basic Information: thumb_helper

A helper that let's you create thumbnails really fast.

Contributor : mpmont
Email : Log in to view
Author Website : http://www.marcomonteiro.net
Spark Website : https://github.com/mpmont/thumb_helper
Repository Type : git
Number of Installs : 2,358

Get the Latest

  • 1.0.3 Pushed July 15th, 2012
    php tools/spark install -v1.0.3 thumb_helper Or download this version manually: Get thumb_helper-1.0.3.zip



  1. Download the repository;

  2. Copy thumb_helper.php to your ./application/helpers/ folder;

That's it, your good to go.


  1. Loading the Helper



After uploading a image you have access to an simple array that has all the information about your image.

Like this:

$image_data = $this->upload->data();

Info on $image_data:

array on $image_data

More information about this here: Codeigniter/userguide/libraries/fileuploading

For now you can pass 4 params to the thumb helper:

  1. Image data from upload;

  2. Width

  3. Height

  4. Destination path

  5. Maintain Aspect Ratio

like this:

create_thumb($image_data, '100', '150', '.public/images/thumbs/', TRUE);

Keep in mind that the 3rd param is optional. If only two params are passed to the thumb helper the thumb will resize the image maintaining the ratio. If theres a 3rd param then, by default the aspect ratio will not be maintained unless the 5th parameter is set to TRUE.

After the creation the thumb helper will return an array with the following content:

path -> The full path to the image;

thumb_marker -> The marker for the thumb, for now will always be equal to the thumb sizes that were passed to the thumb helper;

thumb_name -> The final name of the thumb;

I made this return in case someone needed to sent some of these values to the database for example.


For that insted of passing the array from image upload you can just pass the path to the file (including the file).


create_thumb('./public/images/myimage.jpg', '100', '150');


version 1.0.2

  • Added explicit option for maintaining aspect ratio when height and width are both specified

version 1.0.1

  • Resize image from remote file;

  • Added possibility to choose a different destination path;

version 1.0

  • Resize image after upload with image data;

  • Use just width or both width ad height;

  • Return information about the thumbnail (path / thumbmarker / thumbname )


  • Create crop functions;

Older Versions

  • 1.0.2 Pushed December 14th, 2011
    php tools/spark install -v1.0.2 thumb_helper Or download this version manually: Get thumb_helper-1.0.2.zip


blog comments powered by Disqus