[wp-trac] [WordPress Trac] #43363: Custom URL for Header Video (was: Twenty Seventeen: Custom URL for Header Video)

WordPress Trac noreply at wordpress.org
Sat Apr 6 18:18:25 UTC 2024


#43363: Custom URL for Header Video
-----------------------------+------------------------------
 Reporter:  fbotha           |       Owner:  (none)
     Type:  feature request  |      Status:  new
 Priority:  normal           |   Milestone:  Awaiting Review
Component:  Themes           |     Version:  4.9.4
 Severity:  normal           |  Resolution:
 Keywords:  dev-feedback     |     Focuses:
-----------------------------+------------------------------
Changes (by sabernhardt):

 * component:  Bundled Theme => Themes


Comment:

 This should not be exclusive to Twenty Seventeen.
 - The theme uses `the_custom_header_markup()` in `template-parts/header
 /header-image.php`.
 - I did not find any theme customizations for header video except for the
 play/pause button settings in `twentyseventeen_video_controls()`.
 - The YouTube option is part of
 `WP_Customize_Manager::register_controls()`.

 Maybe the Core functions could be updated to support other custom URLs
 (ticket:38172#comment:44), but the filter could suffice (at least for
 now).

 {{{
 add_filter( 'get_header_video_url', 'wptrac43363_get_header_video_url', 1
 );
 function wptrac43363_get_header_video_url( $url ) {
         $new = str_replace( 'localhost', 'example.com', $url ); // in your
 example, you would want str_replace( 'www.', 'cdn.', $url );
         return $new;
 }
 }}}

 edits the `videoUrl` variable

 {{{
 <script id="wp-custom-header-js-extra">
 var _wpCustomHeaderSettings =
 {"mimeType":"video\/mp4","posterUrl":"http:\/\/localhost\/svn\/src\/wp-
 content\/uploads\/coffee-1.jpg","videoUrl":"http:\/\/example.com\/svn\/src
 \/wp-content\/uploads\/small-
 video2.mp4","width":"2000","height":"1200","minWidth":"900","minHeight":"500","l10n":{"pause":"<span
 class=\"screen-reader-text\">Pause background video<\/span><svg
 class=\"icon icon-pause\" aria-hidden=\"true\" role=\"img\"> <use href
 =\"#icon-pause\" xlink:href=\"#icon-pause\"><\/use> <\/svg>","play":"<span
 class=\"screen-reader-text\">Play background video<\/span><svg
 class=\"icon icon-play\" aria-hidden=\"true\" role=\"img\"> <use href
 =\"#icon-play\" xlink:href=\"#icon-play\"><\/use>
 <\/svg>","pauseSpeak":"Video is paused.","playSpeak":"Video is
 playing."}};
 </script>
 }}}

-- 
Ticket URL: <https://core.trac.wordpress.org/ticket/43363#comment:5>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform


More information about the wp-trac mailing list