You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Currently you can only apply transforms with a preset width and height.
It would be great to be able to use the width and height attributes of the image to create a new transform, with optional math functions.
For example you might have used a 1000x1000 asset resized to 250x250 (via width/height, not actually transformed) but you want to transform it to 250 @2x pixel ratio (so 500x500 transform).
I'm also conscious retconSrcset can be used as an alternative with a bunch of transforms using an auto height (even tho the sizes attribute would still not be set automaitcally based on the width and height attributes), but dynamic transforms based on the actual rendered size could be beneficial.
The text was updated successfully, but these errors were encountered:
Agree it would be useful, and similar use cases have been suggested in the past. The concept of a this variable isn't feasible, but it could probably be implemented if Retcon's filters had support for Twig closures/arrow functions.
This is not something I plan to implement personally, but I'll leave this FR open for a while, in case someone feels the urge to look into opening a PR :)
Hi,
Currently you can only apply transforms with a preset width and height.
It would be great to be able to use the
width
andheight
attributes of the image to create a new transform, with optional math functions.For example you might have used a 1000x1000 asset resized to 250x250 (via width/height, not actually transformed) but you want to transform it to 250 @2x pixel ratio (so 500x500 transform).
Proposed syntax:
{{ entry.body | retconTransform( { width : this.width * 2, height : this.height * 2, mode : 'fit' } ) }}
Alternative syntax:
{{ entry.body | retconTransform( { actualSize : true, pixelRatio: 2, mode : 'fit' } ) }}
I'm also conscious
retconSrcset
can be used as an alternative with a bunch of transforms using an auto height (even tho the sizes attribute would still not be set automaitcally based on the width and height attributes), but dynamic transforms based on the actual rendered size could be beneficial.The text was updated successfully, but these errors were encountered: