fvsch / kirby-twig

Twig templating support for Kirby CMS 2. For Kirby 3, use https://github.com/amteich/kirby-twig
MIT License
70 stars 8 forks source link

Support for resize or thumb #39

Closed mhuegel closed 5 years ago

mhuegel commented 5 years ago

Whats your approach when it comes to resizing images? Kirbys resize and thumb functions don't seem to work?

fvsch commented 5 years ago

I would probably use the thumb method on the image object directly:

$someImage->thumb(...);

You can also expose any PHP function to the Twig environment: https://github.com/fvsch/kirby-twig/blob/main/doc/functions.md

mhuegel commented 5 years ago

This works for me:

but how do i call the thumb-method with multiple options?

fvsch commented 5 years ago

Something like this?

{{ image.thumb({
  width: 300,
  height: 200,
  quality: 80
}).html() }}
mhuegel commented 5 years ago

Awesome, thank you!