Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
// resize an image by the width
// resize by width and height. The bigger one will be downscaled
$image->resize($width, $height)->url();
// adjust the jpeg compression
$image->resize($width, $height, $quality)->url();
// pass null as second argument if you only want to specify the width but also change the quality
$image->resize($width, null, $quality)->url();
// crop an image: by defining only the width the crop will be square
// speificy 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();

bastianallgeier commented Nov 16, 2015

Both methods return a Kirby media object which has tons of additional methods. So you can also do stuff like this:

echo $image->resize(300)->height();

echo $image->resize(300)->niceSize();

echo $image->resize(300)->ratio();

echo $image->resize(300)->orientation();

// etc. 

You can find more about it here:

@bastianallgeier is there still an equivalent of 'grayscale' => true with this new syntax?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment