This module allows you to quickly create resized / cropped images directly through url parameters. Modified images are cached after the initial request and served up thereafter to help reduce server strain.
application/bootstrap.php file modify the call to Kohana::modules and include the image and imagefly modules.
Kohana::modules(array( ... 'image' => MODPATH.'image', 'imagefly' => MODPATH.'imagefly', ... ));
[!!] The image module is requried for the Imagefly module to work.
- Imagefly will not process images when the width and height prams are the same as the source
- Images are scaled up if the supplied width or height params are lager then the source width or height
- Don't forget to make your cache directory writable.
- Inspired by the smart-lencioni-image-resizer by Joe Lencioni
Imagefly has been updated for Kohana 3.3
The default config file is located in
MODPATH/imagefly/config/imagefly.php. You should copy this file to
APPPATH/config/imagefly.php and make changes there, in keeping with the cascading filesystem.
The Imagefly configuration file looks like this:
array( 'cache_expire' => string CACHE_EXPIRE, 'cache_dir' => string CACHE_DIR, 'frame' => FALSE, 'source_dir' => strong SOURCE_DIR, 'mimic_source_dir' => string MIMIC_SOURCE_DIR, 'enforce_presets' => TRUE, 'presets' => array( 'w320-h240-c', ), ),
Understanding each of these settings is important.
How long before the browser checks the server for a new version of the modified image. Default is 1 week (7 * 24 * 60 * 60)
Path to the image cache directory you would like to use, don't forget the trailing slash!
Path to the image directory you would like to use, don't forget the trailing slash!
Mimic the source file folder structure within the cache directory. Useful if you want to keep track of cached files and folders to perhaps periodically clear some cache folders but not others. Default TRUE
Will only allow param configurations entered in the PRESETS array. Recommended for production sites to reduce the impact of spamming different sized images on the server.
Imagefly params to allow when ENFORCE_PRESETS is set to TRUE.
Here are some examples of what you can do with Imagefly.
** Resize image to 300 x 200, and frame into a 300 x 300 square **
** Resize image to either 300 wide or 200 high , and frame into a 300 x 250 box (adding padding) **
Resize to exactly 100px width and height cropping from the center
Resize to exactly 100px width and 150px height cropping from the center
Resize proportionally until width is 100 pixels
Resize proportionally until height is 100 pixels
Resize proportionally until either the width or height is 100 pixels, whichever comes first