Skip to content

Auto-sizes: fall back to next value in sizes if the image is not lazy-loading #9648

Closed

Description

@zcorpan

This may be somewhat off-topic (please feel free to redirect me, if so) but one aspect of the parsing algorithm is still unclear to me. If a platform (e.g. WordPress) generated image markup that looks like this (note the omission of a loading="lazy" attribute):

<img src="200.jpg" width="200" height="200" srcset="200.jpg 200w, 400.jpg 400w, 600.jpg 600w" sizes="auto, 200px" />

Would the omission of the loading attribute cause sizes to be calculates as the default 100vw value, would the 200px value be respected, or would size containment come into play? I would hope that the the "200px" value would be respected in this case so that platforms could add auto to the beginning of a sizes and dynamically decide whether to add a loading attribute while constructing the markup. In other words, if auto can't be applied because the image is not being lazy loaded, then the browser should respect the next items in the media condition.

Originally posted by @joemcgill in #9493 (comment)

Falling back to the next value seems like it could be useful. Maybe make it conforming also.

Activity

  1. added
    topic: img
    on Aug 29, 2023
  2. added a commit that references this issue on Sep 5, 2023
    1b6f84a
  3. zcorpan commented on Sep 5, 2023

    @zcorpan
    MemberAuthor

    Proposed fix as part of #9493

    Didn't make it conforming to use auto when it's not allowed. I think it will be confusing for most people and might restrict us from making auto have an effect in more cases in the future.

  4. manisha765 commented on Sep 14, 2023

    @manisha765
  5. added a commit that references this issue on Oct 3, 2023
    5ee976b
  6. added a commit that references this issue on Mar 10, 2025
    bad27e3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    topic: img

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions