Skip to content

Cover: Enable support for adding posters over video #70816

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

yogeshbhutkar
Copy link
Contributor

What?

Closes #18962

This PR adds support for displaying posters over videos within the Core/Cover block.

Why?

For larger videos and users on slower connections, the inability to set a poster image can result in blocks displaying a blank background, leading to a poor user experience.

How?

The refactorings made in #67044 extracted the poster-image component, which is reused in this PR to implement a similar functionality within the core/cover block.

Testing Instructions

  1. Create a new post and insert a cover block.
  2. Attach a large video to it.
  3. Also, attach a corresponding poster image to the video.
  4. On the front-end, from the developer tools, enable network throttling and set the throttle to "fast 4G".
  5. Confirm that the poster gets shown and acts as a placeholder until the video loads up.

Testing Instructions for Keyboard

Same.

Screencast

pr-demo.mov

@yogeshbhutkar yogeshbhutkar marked this pull request as ready for review July 21, 2025 08:02
Copy link

github-actions bot commented Jul 21, 2025

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.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @VonZubinski, @H0yVoy, @idea--list.

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.

Unlinked contributors: VonZubinski, H0yVoy, idea--list.

Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: donalirl <[email protected]>
Co-authored-by: erikjoling <[email protected]>
Co-authored-by: strarsis <[email protected]>
Co-authored-by: michael-sumner <[email protected]>
Co-authored-by: aatospaja <[email protected]>

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

@t-hamano t-hamano added [Type] Enhancement A suggestion for improvement. [Block] Cover Affects the Cover Block - used to display content laid over a background image labels Jul 21, 2025
Copy link
Member

@fabiankaegy fabiankaegy left a comment

Choose a reason for hiding this comment

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

Very cool! I left one comment that we need to address before we can merge this but other than that I think this works as intended and solves a very old issue :)

@yogeshbhutkar yogeshbhutkar force-pushed the enhance-18962/set-poster-over-cover-with-video branch from 2032b9c to 17c52fd Compare July 21, 2025 10:31
@fabiankaegy
Copy link
Member

CleanShot 2025-07-21 at 12 40 10@2x

Looking at this more I think we should improve the way the poster image is handled here. I'd love to display it similar to the posts featured image where you get a preview of the poster and can then replace / remove it.

CleanShot.2025-07-21.at.12.41.15.mp4

@yogeshbhutkar
Copy link
Contributor Author

I agree with this, @fabiankaegy. The current UI for previewing poster images definitely needs some iteration. That said, this has also been the case for the Video Block, where poster image support has existed for some time now.

In my opinion, this PR is simply adding poster image support in line with what's already available in the Video Block. With that in mind, I think it would make sense to handle the design enhancements for both blocks as part of a follow-up issue. What do you think?

@fabiankaegy
Copy link
Member

@yogeshbhutkar Very good point! :)

I hadn't realized that the video block uses the exact same control.

In that case I'm happy with this 👍 :)

@fabiankaegy fabiankaegy requested review from Mamaduka and t-hamano July 21, 2025 10:54
@fabiankaegy
Copy link
Member

I just requested an additional final review from @t-hamano or @Mamaduka but from my end this is good to go

@t-hamano
Copy link
Contributor

t-hamano commented Jul 22, 2025

I think we should improve the way the poster image is handled here. I'd love to display it similar to the posts featured image where you get a preview of the poster and can then replace / remove it.

I agree. The current PosterImage UI makes it difficult to preview poster images. We may be able to try to improve it with a separate PR.

@Mamaduka
Copy link
Member

I think we should improve the way the poster image is handled here. I'd love to display it similar to the posts featured image where you get a preview of the poster and can then replace / remove it.

+1. Makes sense as a follow-up.

Copy link
Member

@Mamaduka Mamaduka left a comment

Choose a reason for hiding this comment

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

Thanks for working on this, @yogeshbhutkar!

The new poster image control works as expected, and I couldn't identify any regressions when testing the previous block markup.

A small note: Maybe we should place a new control below the 'Focal point' picker. IMO, seems less distracting and secondary with this order. @fabiankaegy, @t-hamano, what do you think?

Screenshot

CleanShot 2025-07-22 at 12 35 28

Copy link
Contributor

@t-hamano t-hamano left a comment

Choose a reason for hiding this comment

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

Maybe we should place a new control below the 'Focal point' picker. IMO, seems less distracting and secondary with this order.

+1 👍

As a follow-up, it would be great to improve the PosterImage component of the Video block based on this feedback as well (Correctly place the MediaUploadCheck, use ref suffix, etc.).

@Mamaduka
Copy link
Member

As a follow-up, it would be great to improve the PosterImage component of the Video block based on this feedback as well (Correctly place the MediaUploadCheck, use ref suffix, etc.).

We got that covered in #70830.

* Duplicates poster-image from video to cover block.
* Suffix refs with `Ref`
* use string overload for `useInstanceId`
* This change should prevent the ToolsPanelItem from rendering unnecessarily.
* Updates the ordering of PosterImage to be displayed after FocalPointPicker
* Adds a period to screen-reader text
@yogeshbhutkar yogeshbhutkar force-pushed the enhance-18962/set-poster-over-cover-with-video branch from 589307a to 7b20a93 Compare July 23, 2025 03:44
@yogeshbhutkar
Copy link
Contributor Author

The MediaUpload component supports pre-selecting images via attachment IDs, but this isn’t currently implemented. To enable this, we may need to introduce a posterId attribute in the block.json for the Video and Cover blocks.

I would like to know your thoughts on whether this is a viable approach and if it requires a follow-up.

@Mamaduka Mamaduka merged commit 934e850 into WordPress:trunk Jul 23, 2025
62 checks passed
@github-actions github-actions bot added this to the Gutenberg 21.3 milestone Jul 23, 2025
@Mamaduka
Copy link
Member

The MediaUpload component supports pre-selecting images via attachment IDs, but this isn’t currently implemented. To enable this, we may need to introduce a posterId attribute in the block.json for the Video and Cover blocks.

I've not seen any reports requesting the fix for it. While a nice QoL improvement, it doesn't seem to be a significant issue for users. I would say it's a very low priority.

@yogeshbhutkar yogeshbhutkar deleted the enhance-18962/set-poster-over-cover-with-video branch July 23, 2025 05:01
USERSATOSHI pushed a commit to USERSATOSHI/gutenberg that referenced this pull request Jul 23, 2025
Unlinked contributors: VonZubinski, H0yVoy, idea--list.

Co-authored-by: yogeshbhutkar <[email protected]>
Co-authored-by: fabiankaegy <[email protected]>
Co-authored-by: t-hamano <[email protected]>
Co-authored-by: Mamaduka <[email protected]>
Co-authored-by: donalirl <[email protected]>
Co-authored-by: erikjoling <[email protected]>
Co-authored-by: strarsis <[email protected]>
Co-authored-by: michael-sumner <[email protected]>
Co-authored-by: aatospaja <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Block] Cover Affects the Cover Block - used to display content laid over a background image [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Cover block with video: no option to set a poster
4 participants