Cms: getSrcset on existing transform does not copy same settings as original transform (e.g.: interlacing and quality)

Created on 27 Nov 2020  路  2Comments  路  Source: craftcms/cms

Description

Whenever you attempt to get a srcset from an existing transforms it does not copy settings like interlacing and quality. As far as I know it only covers: default focal point, width, height and image format.

Steps to reproduce

  1. Create a transform (in my case I made 2 identical transforms with only the format differing from jpeg to webp as I need 2 kinds of srcsets)
    Schermafbeelding 2020-11-27 om 14 16 30

  2. Use this twig code

  {% set image = entry.myImage.one() ?? null %}
  {% if image %}
       <picture>
            {% set webpSrcset = image.setTransform("textImageWebp").getSrcset([360, 600, 1200]) %}
            {% set defaultSrcset = image.setTransform("textImage").getSrcset([360, 600, 1200]) %}
            {% set fallbackJpeg = defaultSrcset|split(' ')|first %}

            <source sizes="(min-width: 900px) 40vw, calc(100vw - 52px)" srcset="{{ webpSrcset }}" type="image/webp">
            <source sizes="(min-width: 900px) 40vw, calc(100vw - 52px)" srcset="{{ defaultSrcset }}" type="image/jpeg">
            <img src="{{ fallbackJpeg }}" alt="{{ image.title }}" loading="lazy">
       </picture>
  {% endif %}
  1. Inspect the html output
    Image 2020-11-27 at 2 20 21 PM

Additional info

  • Craft version: Craft Pro 3.5.16
  • PHP version: 7.4.9
  • Database driver & version: MySQL 5.7.30
  • Plugins & versions: n/a
bug normal

All 2 comments

Thanks for reporting that. Just fixed it for the next release!

Craft 3.5.17 is out now with this fix.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

rynpsc picture rynpsc  路  3Comments

angrybrad picture angrybrad  路  3Comments

RitterKnightCreative picture RitterKnightCreative  路  3Comments

davist11 picture davist11  路  3Comments

mattstein picture mattstein  路  3Comments