thumb($image, $params = array(), $obj = true)

Creates a thumbnail for a given image object

  • $image (string or Media)
  • $params (array)
    Additional options
  • $obj (boolean)
    Whether to return a thumb object or the URL to the thumb only
  • return ($thumb or URL string)

Example

<?php
// return thumb and just set the width
echo thumb($page->image(), array('width' => 300));
// return thumb and set width + height
echo thumb($image, array('width' => 400, 'height' => 250));
// return thumb and set width + height + crop
echo thumb($image, array('width' => 400, 'height' => 250, 'crop' => true));
// return thumb and set width + height + upscale
echo thumb($image, array('width' => 400, 'height' => 250, 'upscale' => true));
// return thumb and set width + height + quality
echo thumb($image, array('width' => 400, 'height' => 250, 'quality' => 70));
// return thumb and set width + height + grayscale
echo thumb($image, array('width' => 400, 'height' => 250, 'grayscale' => true));
// return thumb and set width + height + blur
echo thumb($image, array('width' => 400, 'height' => 250, 'blur' => true));
// return url of the thumb
echo thumb($image, array('width' => 400, 'height' => 250))->url();
// return width of the thumb
echo thumb($image, array('width' => 400, 'height' => 250))->width();
// return height of the thumb
echo thumb($image, array('width' => 400, 'height' => 250))->height();
// return file size of the thumb
echo thumb($image, array('width' => 400, 'height' => 250))->niceSize();
// return url of the thumb's original file
echo thumb($image)->source()->url();
// return width of the thumb's original file
echo thumb($image)->source()->width();
// return height of the thumb's original file
echo thumb($image)->source()->height();
// return file size of the thumb's original file
echo thumb($image)->source()->niceSize();
// return extension of the thumb's original file
echo thumb($image)->source()->extension();
?>

Is something missing or incorrect? Edit this page on Github…