[wp-trac] [WordPress Trac] #42718: Video shortcode needs muted attribute for Autoplay to work with Safari 11.0.1+

WordPress Trac noreply at wordpress.org
Wed Dec 19 14:28:18 UTC 2018


#42718: Video shortcode needs muted attribute for Autoplay to work with Safari
11.0.1+
--------------------------------------+------------------------------
 Reporter:  deeptiboddapati           |       Owner:  (none)
     Type:  defect (bug)              |      Status:  new
 Priority:  normal                    |   Milestone:  Awaiting Review
Component:  Shortcodes                |     Version:  3.6
 Severity:  normal                    |  Resolution:
 Keywords:  has-patch has-unit-tests  |     Focuses:
--------------------------------------+------------------------------

Comment (by simdri):

 If you set this in line 2596 of wp-includes\media.php, in function
 wp_video_shortcode:
 {{{
   if(isset($html_atts['autoplay'])){
     $html_atts['muted'] = '1';
   }
 }}}

 This snippet must be after

 {{{
         // These ones should just be omitted altogether if they are blank
         foreach ( array( 'poster', 'loop', 'autoplay', 'preload' ) as $a )
 {
                 if ( empty( $html_atts[$a] ) ) {
                         unset( $html_atts[$a] );
                 }
         }
 }}}


 This sets the attribute muted to 1, when autoplay is set, regardless of
 what is set.
 Works with Chrome. No other where tested.

 Any shortcomings with this change?

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


More information about the wp-trac mailing list