-
Notifications
You must be signed in to change notification settings - Fork 4.4k
Fix layout shift caused by video
tag in Video block lacking width
and height
#70293
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
base: trunk
Are you sure you want to change the base?
Conversation
Size Change: +26 B (0%) Total Size: 1.85 MB
ℹ️ View Unchanged
|
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 Unlinked AccountsThe following contributors have not linked their GitHub and WordPress.org accounts: @porg. Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases. If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
@@ -3,6 +3,7 @@ | |||
box-sizing: border-box; | |||
video { | |||
width: 100%; | |||
height: auto; |
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.
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.
Flaky tests detected in c048eb8. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/15459358151
|
@Mamaduka anything else you want to see here prior to working on a backport PR for core? |
What?
Fixes #52185
When adding a video from the Media Library to a Video block, this supplies the
width
andheight
attributes for the Video based on the dimensions in metadata if available. The dimensions are also supplied in an inlineaspect-ratio
style (due to w3c/csswg-drafts#7524) to go along with aheight:auto
style (originally proposed in #37052 as a follow-up to #30092). We can't yet useaspect-ratio
withattr()
in a rule like this since it's not yet supported in Firefox or Safari:The changes in this PR are also available in a standalone plugin for existing sites to use before the change is published in a Gutenberg release: Layout-stabilized Video Block.
See blog post with full writeup: Eliminating Layout Shifts in the Video Block
Why?
This eliminates a layout shift which occurs while the video loads. The result is an improved Cumulative Layout Shift (CLS) metric for Core Web Vitals.
Testing Instructions
Screenshots or screencast
intrinsic-dimensions-before.webm
intrinsic-dimensions-after.webm