Skip to content

Instantly share code, notes, and snippets.

@eduardo-marcolino
Created June 25, 2012 19:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardo-marcolino/2990774 to your computer and use it in GitHub Desktop.
Save eduardo-marcolino/2990774 to your computer and use it in GitHub Desktop.
Symfony timthumb generator helper
<?php
/**
* Timthumb Helper
* Helper para geração de thumbnails com o timthumb
*
* @see http://www.binarymoon.co.uk/projects/timthumb/
* @author Eduardo Marcolino <eduardo.marcolino@gmail.com>
*
* @param source $image url to image
* @param width $width the width to resize to
* @param height $height the height to resize to
* @param type $quality 0 - 100
* @param type $alignment c, t, l, r, b, tl, tr, bl, br
* @param type $zoom_crop 0, 1, 2, 3
* @return timthumb image
*/
function timthumb($image, $width = 0, $height = 0, $quality = 100, $alignment = 'c', $zoom_crop = 0)
{
$params = array(
'w='.$width,
'h='.$height,
'q='.$quality,
'src='.$image,
'a='.$alignment,
'zc='.$zoom_crop
);
return image_tag(_compute_public_path('/timthumb.php','','php',true).'?'.join('&',$params));
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment