Skip to content

Feature request: dynamic image transform based on the width and height attributes of the img tag #47

@uandco

Description

@uandco

Hi,

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).

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.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions