Thumbnailer - Flexible thumbnail generation in one line of code! |
[eluser]Unknown[/eluser]
This is my first contribution to the Code Igniter community. I'm still somewhat new here, so I doubt this is anything especially new or different, but I had fun making it and that's all that matters I guess. -shrugs- Anyway, what I have for you is a really simple thumbnail generation helper. It supports multiple scale modes, can generate more than one size of thumbnail for the same image, and best of all; only uses one line of code! Here's the code for thumbnailer_helper.php Code: <? if (!defined('BASEPATH')) exit('No direct script access allowed.'); To generate a thumbnail you just need to use this line; Code: <img src="<?=thumbnailer("image.jpg", "path/to/file/", 100, 'auto')?>" /> The last two values are the scale value and mode. Both are optional and set to 100 pixels for value and auto for mode by default. The mode can also be 'x' or 'y', which will limit scaling only on that particular dimension, while auto figures out which side is larger and sets it's maximum to the scale value . That line of code will tell Thumbnailer to see if a thumbnail exists with those settings and, if not, it will generate one for you. It works quite handily if you place it in a loop. You may or may not want to make a few changes so it doesn't try and save thumbnails in a thumbs folder at the original image's path...it wouldn't work so great for thumbnailing images off a different server. |
Messages In This Thread |
Thumbnailer - Flexible thumbnail generation in one line of code! - by El Forum - 03-25-2008, 11:17 PM
Thumbnailer - Flexible thumbnail generation in one line of code! - by El Forum - 04-18-2008, 12:55 AM
Thumbnailer - Flexible thumbnail generation in one line of code! - by El Forum - 04-18-2008, 09:05 AM
Thumbnailer - Flexible thumbnail generation in one line of code! - by El Forum - 04-18-2008, 10:11 AM
Thumbnailer - Flexible thumbnail generation in one line of code! - by El Forum - 05-06-2009, 07:00 AM
|