[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
Fri Jul 10 10:19:58 UTC 2020
#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 stepan1860):
You should write these filter in your functions.php
{{{
add_filter( 'wp_video_shortcode', function( $html ) {
return str_replace( '<video', '<video muted playsinline autoplay',
$html );
} );
}}}
also you must initalized your shortcode in index.php or category.php (or
somewhere else =))
{{{
$post_id = get_the_ID();
$media = get_attached_media('video', $post_id);
echo wp_video_shortcode( [
'src' => $media[0],\\
'loop' => 'true',\\
'poster' => 'your_poster',\\
'preload' => 'yes',\\
'fullscreen'=> 'false',\\
'class' => 'jquery-background-video is-playing is-visible',\\
'id' => '',
] );
}}}
--
Ticket URL: <https://core.trac.wordpress.org/ticket/42718#comment:8>
WordPress Trac <https://core.trac.wordpress.org/>
WordPress publishing platform
More information about the wp-trac
mailing list