mmikkel / Retcon-Craft

A collection of powerful Twig filters for modifying HTML
MIT License
79 stars 9 forks source link

Setting imager config / imgixProfile for retconSrcset #29

Closed hongc-cc closed 3 years ago

hongc-cc commented 4 years ago

Retcon use the default imager config for image transform.

Any chance we can pass imager config / imgixProfile etc in the code?

// current

{{ richTextEditor 
    | retconSrcset(
        [
            {width: 160},
        ],
        'img',
        'auto',
        true
    )
sonoflee commented 3 years ago

Seconded - wondering how I can retcon and use srcset with imgix here. Thanks!

aelvan commented 3 years ago

This is already possible, just not documented.

{{ entry.text
            | retconSrcset(
                [
                    {width: 375},
                    {width: 480},
                    {width: 768}
                ],
                'img',
                '(min-width: 40em) 80vw, 100vw',
                true,
                { ratio: 16/9 },
                { imgixProfile: 'proxy' }
        ) }}

The fifth parameter is Imager's transform defaults, the sixth is Imager config overrides.

Worth noting that Retcon gets the parsed URLs from Craft, so you need to use an Imgix source/profile that is a "Web Proxy" for it to work with Imgix.