-
Notifications
You must be signed in to change notification settings - Fork 4.6k
Cover: add support for background videos as embeds. #73023
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
Conversation
This extends background video support to other core video embeds, like YouTube, Vimeo, etc.
|
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: @amandablum, @ivcreative, @badlydrawnben, @mammothsolutions, @miriamardent, @kblizeck, @losbenos, @LetterAfterZ, @scrybbler, @nebmotion. 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. |
|
Size Change: +1.4 kB (+0.06%) Total Size: 2.47 MB
ℹ️ View Unchanged
|
|
Flaky tests detected in 26d9e4c. 🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/19214336552
|
| ); | ||
|
|
||
| setAttributes( { | ||
| embedSrc: backgroundVideoSrc, |
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.
This is a bit weird, why are we loading the iframe of the embed extraction the src ... Can't we just render the iframe directly (like we do in the frontend I guess)
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 guess we should check how the embed preview works in the embed block and do the same.
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.
Looking at the Embed block looks the logic is a bit involved and implemented in EmbedPreview. I wonder if we should have a similar logic using the Sandbox component.
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.
Alternatively, maybe all this processing can happen in EmbedVideoUrlInput or in the submit callback.
The embed block has to do it during rendering as a side effect, because it deals with embeddable URLs and converts them into iframes, which mimics how WordPress handles this on the front end.
|
Loving it so far! The default overlay opacity is 100, making it impossible to see the video if you don't know how to adjust it. |
|
Once the video is added, replacing it with a new one becomes difficult because the video URL field stays empty. The user can swap a video for another by first resetting the cover block. |
| // Use WordPress's native oEmbed processing (includes caching). | ||
| $oembed_html = wp_oembed_get( $url ); | ||
|
|
||
| if ( $oembed_html ) { |
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 like that this logic is contained now, I think probably we could also guess the embedProvider from the html like we do in frontend to avoid the extra attribute.
|
Looks like YouTube is broken on the editor but works on the frontend. |
| { isEmbedVideoBackground && url && ( | ||
| <figure | ||
| className={ clsx( | ||
| 'wp-block-cover__video-background', |
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.
Is this classname needed or should we clearly separate the "embed" from the "video" background rendering/classes?
youknowriad
left a comment
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.
This is looking good to me in terms of flow / code / behavior. I don't know if we could fix the YouTube preview in the editor. Other than that I left small comments but no big things.
I thought it was a bit much, so we could start by adding the support in the dropdown only. |
|
Ok I tested this on playground and it works great. Youtube has issues when it comes to localhost. |
youknowriad
left a comment
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 this is working great for me. IT would have been great if oembed's supported the "no buttons" approach more easily but the code is contained and can be improved later.
|
Thanks for the review! |

Closes #28860
This extends background video support in
core/coverto other core video embeds, like YouTube, Vimeo, etc.Implementation notes: