mmikkel / Retcon-Craft

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

Srcset not fetching all values for named transform #69

Closed anita-chouhan closed 2 months ago

anita-chouhan commented 2 months ago

Hi, I am trying to generate image transforms using a named transform but it's not working as expected.

Steps to repoduce

Add a named transform to imager-x-transforms.php:

return [
      'banner' => [
        'transforms' => [
            ['width' => 600],
            ['width' => 1200],
            ['width' => 1800],
        ],
    ],
];

Try to use it in retconSrcset

{{ entry.body|retconSrcset([
    'banner',
    {width: 400},
]) }}

Expected Output

<img src="../path/image.jpg" srcset="../path/image_W600.jpg 600w, ../path/image_W1200.jpg 1200w, ../path/image_W1800.jpg 1800w, ../path/image_W400.jpg 400w">

Actual Output

<img src="../path/image.jpg" srcset="../path/image_W600.jpg 600w, ./path/image_W400.jpg 400w">

Additional info

Retcon version: 2.7.5 Craft version: 4.9.7 PHP version: 8.0.2

mmikkel commented 2 months ago

Thanks for reporting that. I just tagged Retcon 2.8.0 and 3.2.0 with a fix, for Craft 4 and Craft 5 respectively.

anita-chouhan commented 2 months ago

Thank you for the quick turnaround. The named transforms are now functioning perfectly.

bymayo commented 2 months ago

@mmikkel Since this update we now get this issue

CleanShot 2024-07-03 at 14 42 35

We don't seem to be using the retconSrcset filter at all, but we do have ImagerX installed

mmikkel commented 2 months ago

@mmikkel Since this update we now get this issue

Sorry about that @bymayo. What's your Craft CMS and PHP version?

mmikkel commented 2 months ago

@bymayo That was a PHP 7 compatibility issue that was obvious as soon as I plugged in my brain 🙃 Just tagged Retcon 2.8.1 for Craft 3.x and 4.x with a fix.

bymayo commented 2 months ago

@mmikkel Amazing! Thanks!