I get Undefined variable: for $video, $post_id and $library and the
video’s in the page are blank.
Replace:
add_filter( 'wp_video_shortcode', 'my_video_shortcode', 10, 2 );
with:
add_filter( 'wp_video_shortcode', 'my_video_shortcode', 10, 5 );
to access all five input arguments in your filter’s callback.
ps: my_
is such a common prefix, that I would consider something more unique.
pps: Here’s another approach by overriding the shortcode:
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 );
} );
where the muted
attribute is activated with:
Hope you can adjust it to your needs!