Image Actions on retina images @2x

Hi Grav Team!

Is it somehow possible to use image actions like cropResize(width, height) with retina images?

For example: put some image inside a page folder, name it image@2x.jpg then call an action inside the twig template like this{{ image.cropZoom(650,550).html('','',page.header.image_align) }} . This will result in an error.

Which error do you get?

I’m really sorry but I cannot provide any information more than this. There’s no error inside the logs or in the debugger console. It just renders as an error-fallback image.

Bildschirmfoto 2016-11-21 um 19

Getting same error image after updating Grav from v1.1.5 to v1.1.8 with all images on which I manually added a @3x in the file name. Based on the Grav version changelog there has been changes made to how retina images should be named, although in Grav docs @3x is still mentioned (but maybe not yet updated?). Wasn’t able to yet go into details.

Did you manage to find a fix?

After reading a bit more in-depth in the documentation it seems it would be anyway cleverer to make Grav create the various image sizes automatically by defining it in the Twig template file, without manually adding a @3x for all the images you want it applied to. You can do this like described in the Sizes with media queries section.

I still get the error if I first create the derivatives and then apply the cropZoom. I believe this makes sense, because if you apply a cropZoom with a defined resolution value to a bunch of images with different resolutions for different screen sizes, it would basically mean they would all get the same resolution again. And that wouldn’t make any sense at all since you want to have different sizes.

If you first do the cropZoom and then make Grav create derivatives it works. So something like this:

{{ image.cropZoom(650, 550).derivatives(320, 1440, 100).html('','',page.header.image_align) }}
---

Thanks mate! This helps a lot!

Derivatives have just been updated to support a custom array of sizes you wish to create. This will be available in the next RC version of Grav.