Add Filter to Show Cover Image When Self-Hosted Video Ends#2292
Add Filter to Show Cover Image When Self-Hosted Video Ends#2292
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
I'm having trouble getting both widgets/video/js/so-video-widget.js to output (it has a specific set of requirements) and the |
|
You were right. The requirements were too strict. Before this change, the filter would only work when I have loosened that now in I also adjusted the JS initialization so repeated That should make the filter work with the normal self-hosted video setup as well. |
AlexGStapleton
left a comment
There was a problem hiding this comment.
Thanks for changing that. I don't see any direct issues with those changes and the cover now appears for me after the video finishes. Strangely, the image displays differently after playing. Are you getting this? This happens with every image I've tested so I don't think it's image specific.
Before play:
After play:
| $video_args['controls'] = ''; | ||
| } | ||
|
|
||
| if ( apply_filters( 'sow_video_show_cover_on_end', false, $instance ) ) { |
There was a problem hiding this comment.
The value returned by apply_filters should ideally be typecast as a bool.
No need to do further validation beyond this. This is just to ensure a valid value is returned, and the contents are irrelevant).
|
@AlexGStapleton I've pushed follow-up changes in 5d12b65. For the inline review point, For the poster rendering issue, I removed the generic I haven't done a browser pass yet on my side, so if you get a chance to retest the controls-enabled self-hosted case, that would be useful. |
AlexGStapleton
left a comment
There was a problem hiding this comment.
Browser pass looks good. Cover is now the correct size after the video finishes.
Summary
sow_video_show_cover_on_endfilter (defaults tofalse) that, when enabled, resets a self-hosted video back to its poster/cover image after playback ends instead of freezing on the last frame.add_filter( 'sow_video_show_cover_on_end', '__return_true' );How it works
data-show-cover-on-endattribute to the<video>element via the existing$video_argsarray.endedevent and callsvideo.load()to reset the player to its initial state, re-displaying the poster image.Test plan
ended)🤖 Generated with Claude Code