mmikkel/Retcon-Craft

Setting imager config / imgixProfile for retconSrcset

hongc-cc opened this issue · 2 comments

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
    )

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

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.