$media->crop($width, $height = null, $quality = null)

Crops the file according to the given parameters

  • $width (integer)
  • $height (integer)
  • $quality (integer)
    JPEG quality from 0 to 100
  • return ($media)
    Kirby media object with the given parameters

The new syntax is a shorthand for the old thumb() syntax. See $file->resize() for resizing images on the fly.


// crop an image: by defining only the width the crop will be square
// specificy a width and height to get non-square crops
$image->crop($width, $height)->url();
// adjust the jpeg compression 
$image->crop($width, $height, $quality)->url();
// pass null again for the height if you want a square crop but also adjust the quality
$image->crop($width, null, $quality)->url();

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