admin管理员组

文章数量:1293670

I am trying to add onmouseover="this.play()" onmouseout="this.pause()" to the default <video element in Wordpress. I am using Gutenberg block editor.

By default, this is what the output from the video block looks like in HTML:

<video src=".mp4"></video>

I want it to be like this:

<video onmouseover="this.play()" onmouseout="this.pause()" src=".mp4"></video>

I want to add the onmouseover="this.play()" onmouseout="this.pause()" to the default video element.

I have tried the below filter but it's not working:

add_filter( 'wp_video_shortcode', function( $output ) {
    $output = str_replace( '<video', '<video onmouseover="this.play()" onmouseout="this.pause()"', $output );
    return $output;
} );

Am I doing something wrong? Any help would be greatly appreciated.

Thanks.

本文标签: functionsCustomizing the wpvideoshortcode output with addfilter