Created
May 18, 2021 13:26
-
-
Save marklchaves/3de664aef48c66aa28ba981321e6e69b to your computer and use it in GitHub Desktop.
Add muted and playsinline attributes to WordPress generated video tag to force autoplay on mobile.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php // Ignore this line when adding to your child theme functions.php file. | |
/** || Add muted and playsinline to force autoplay on mobile. */ | |
add_filter( 'wp_video_shortcode', function( $html ) { | |
return str_replace( '<video', '<video muted playsinline ', $html ); | |
} ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment