Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
✨Add
img-sizes
attribute toamp-img
. #24223✨Add
img-sizes
attribute toamp-img
. #24223Changes from 2 commits
e8c3e59
31ddaf4
b5fcd3d
464f260
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what this does.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reworded, see updated text
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still don't understand why this is necessary. Why wouldn't they just use
sizes
? How does having<amp-img img-sizes="..."><img sizes="..."></amp-img>
have a different behavior than<amp-img sizes="..."><img sizes="..."></amp-img>
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because of what
sizes
does in AMP: https://amp.dev/documentation/guides-and-tutorials/learn/common_attributes/#sizesUnfortunately, AMP sets the width of an element based on the value that the
sizes
attribute resolves to. This prevents developers from usingsizes
, since they want it for picking the source, but do not want to actually set the<amp-img>
to that width.Since this behavior already exists, we cannot remove it (from
amp-img
or any other element).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For context, we discussed this in design review some time ago: #11575 (comment). I did not implement
img-sizes
because we thought thatauto-sizes
would suffice for most cases (and it did for WP), but from #21736, it seems like we do need a way to explicitly set<img>
sizes
without accidentally also setting AMPsizes
. Sizes always has a side effect in AMP, and we could not remove that side effect due to backwards compatibility issues, hence the unfortunate introduction of a new attribute.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a few demos:
Given the
img-sizes
and manualsizes
are incompatible together, I think we need to ban using both at the same time. And if we do that, we could probably use a boolean attribute instead, saying, "behave like regular sizes".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it comes down to which one of these is syntactically less confusing:
(Src: #11575 (comment))
Either will achieve the intended purpose.