[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
Tue Nov 28 02:36:05 UTC 2017


#42718: Video shortcode needs muted attribute for Autoplay to work with Safari
11.0.1+
--------------------------------------+------------------------------
 Reporter:  deeptiboddapati           |       Owner:
     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:
--------------------------------------+------------------------------
Changes (by birgire):

 * keywords:   => has-patch has-unit-tests
 * version:  trunk => 3.6


Comment:

 @deeptiboddapati thanks for the info on this matter.

 [attachment:42718.diff] is a first pass at supporting the {{{muted}}}
 video shortcode attribute.

 It also contains an update for the attributes test in
 {{{Tests_Media::test_wp_video_shortcode_attributes()}}}.

 ps: The shortest hack I can currently think of to support this, is
 something like:

 {{{
 add_shortcode( 'video', function ( $atts, $content )
 {
     $output = wp_video_shortcode( $atts, $content );

     if( ! isset( $atts['muted'] ) || ! wp_validate_boolean( $atts['muted']
 ) )
         return $output;

     if( false !== stripos( $output, ' muted="1"' ) )
         return $output;

     return str_ireplace( '<video ', '<video muted="1" ', $output );
 } );

 }}}

 but watch out that his actually replaces the default video shortcode's
 callback.

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


More information about the wp-trac mailing list