因此,您可以将视频放在一个短代码中,然后可以对该短代码函数运行过滤器。工作原理如下(放在functions.php或一些自定义插件中):
function so327822_wp_video_shortcode($output, $atts) {
//get video ID by src
$video_id = attachment_url_to_postid( $atts[\'src\'] );
//get video meta
$video_meta = wp_get_attachment_metadata( $video_id );
//uncomment next line, to view all meta
//echo \'<pre>\' . print_r($video_meta, true) . \'</pre>\';
if ( $video_meta[\'fileformat\'] === \'mp4\' ) {
//mess with $output here, if we have mp4
}
//return
return $output;
}
add_filter(\'wp_video_shortcode\', \'so327822_wp_video_shortcode\', 10, 2);