The header_video_settings WordPress PHP Filter allows you to modify the settings of the header video in your WordPress theme.
Usage
add_filter( 'header_video_settings', 'my_custom_header_video_settings' ); function my_custom_header_video_settings( $settings ) { // your custom code here return $settings; }
Parameters
$settings
(array) – An array of header video settings that you can modify.- ‘mimeType’ => ”,
- ‘posterUrl’ => get_header_image(),
- ‘videoUrl’ => $video_url,
- ‘width’ => absint( $header->width ),
- ‘height’ => absint( $header->height ),
- ‘minWidth’ => 900,
- ‘minHeight’ => 500,
- ‘l10n’ => array(
- ‘pause’ => __( ‘Pause’ ),
- ‘play’ => __( ‘Play’ ),
- ‘pauseSpeak’ => __( ‘Video is paused.’ ),
- ‘playSpeak’ => __( ‘Video is playing.’ ),
- ),
- );
More information
See WordPress Developer Resources: header_video_settings
Examples
Change the minimum width and height of the header video
Modify the minimum width and height of the header video to fit your theme’s design.
add_filter( 'header_video_settings', 'change_min_width_height' ); function change_min_width_height( $settings ) { $settings['minWidth'] = 1200; $settings['minHeight'] = 700; return $settings; }
Customize the poster URL
Use a custom image URL as the poster for the header video.
add_filter( 'header_video_settings', 'change_poster_url' ); function change_poster_url( $settings ) { $settings['posterUrl'] = 'https://example.com/custom-poster.jpg'; return $settings; }
Change the MIME type
Set a custom MIME type for the header video.
add_filter( 'header_video_settings', 'change_mime_type' ); function change_mime_type( $settings ) { $settings['mimeType'] = 'video/webm'; return $settings; }
Update the play and pause text
Change the text displayed for the play and pause buttons in the header video.
add_filter( 'header_video_settings', 'update_play_pause_text' ); function update_play_pause_text( $settings ) { $settings['l10n']['pause'] = __( 'Stop' ); $settings['l10n']['play'] = __( 'Start' ); return $settings; }
Modify header video dimensions
Adjust the width and height of the header video.
add_filter( 'header_video_settings', 'change_header_video_dimensions' ); function change_header_video_dimensions( $settings ) { $settings['width'] = 1280; $settings['height'] = 720; return $settings; }