Skip to content

Instantly share code, notes, and snippets.

@pramod1988
Last active May 4, 2017 07:45
Show Gist options
  • Save pramod1988/a2b129b4188706663d26c8643dcc8f64 to your computer and use it in GitHub Desktop.
Save pramod1988/a2b129b4188706663d26c8643dcc8f64 to your computer and use it in GitHub Desktop.
<?php
function imageUrl($path, $width = NULL, $height = NULL,$quality=NULL,$crop=NULL) {
 
if(!$width && !$height) {
$url = env(‘IMAGE_URL’) . $path;
} else {
$url = url(‘/’) . ‘/timthumb.php?src=’ . env(‘IMAGE_URL’) . $path;
if(isset($width)) {
$url .= ‘&w=’ . $width; 
}
if(isset($height) && $height>0) {
$url .= ‘&h=’ .$height;
}
if(isset($crop))
{
$url .= “&zc=”.$crop;
}
else
{
$url .= “&zc=1”;
}
if(isset($quality))
{
$url .=’&q=’.$quality.’&s=1';
}
else
{
$url .=’&q=95&s=1';
}
}
 
 return $url;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment