Skip to content
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

Auto-sizes: Align CSS rule with Google Chrome implementation #7896

Conversation

mukeshpanchal27
Copy link
Member

@mukeshpanchal27 mukeshpanchal27 commented Nov 26, 2024

Trac ticket: https://core.trac.wordpress.org/ticket/62515


This Pull Request is for code review only. Please keep all other discussion in the Trac ticket. Do not merge this Pull Request. See GitHub Pull Requests for Code Review in the Core Handbook for more details.

Copy link

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • The Plugin and Theme Directories cannot be accessed within Playground.
  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@mukeshpanchal27
Copy link
Member Author

These PR update core CSS to align with Google Chrome implementation. In most issue the sites uses height:auto CSS rules so it will stretch to 1500px per CSS that implemented through PR #7813.

Per https://issues.chromium.org/issues/352077687#comment5, either we should pass the height & width for image or it will load 300X150 dimensions.

This is working as intended based on the spec definition for sizes="auto"

The user agent stylesheet change is based on the rendering section of the html spec:
https://html.spec.whatwg.org/#img-contain-size

The following note is present in the spec:
"In addition, it is strongly encouraged to specify dimensions using the width and height attributes or with CSS. Without specified dimensions, the image will likely render with 300x150 dimensions because sizes="auto" implies contain-intrinsic-size: 300px 150px in the Rendering section."
https://html.spec.whatwg.org/#sizes-attributes

Specifying the images dimensions should work around this problem.

@mukeshpanchal27 mukeshpanchal27 marked this pull request as ready for review November 26, 2024 15:43
Copy link

github-actions bot commented Nov 26, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Core Committers: Use this line as a base for the props when committing in SVN:

Props mukesh27, flixos90, joemcgill.

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

Copy link
Member

@felixarntz felixarntz left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mukeshpanchal27 This is not a proper fix, as it breaks the behavior again that this is fixing in the first place.

We must not use exactly what Google Chrome uses, because that's precisely what caused the other bug.

Copy link
Member

@joemcgill joemcgill left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @mukeshpanchal27, but the dimensions added here were intentionally made larger than the default UA stylesheet in Chrome in #7813.

I'd suggest closing this PR.

@mukeshpanchal27
Copy link
Member Author

@mukeshpanchal27 This is not a proper fix, as it breaks the behavior again that this is fixing in the first place.

We must not use exactly what Google Chrome uses, because that's precisely what caused the other bug.

Thanks for review. As a side effect how we solve the height issue for image as chrome return 150px and WP core return 1500px?

@mukeshpanchal27
Copy link
Member Author

Closing as it re-introduce original issue reported at https://core.trac.wordpress.org/ticket/62413

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants