WordPress video标签是插入视频时,自动加载了播放器而生成的标签,这个标签会根据 content_width
设置的宽度而生成视频宽度。
- function info_content_width() {
- if( wp_is_mobile() ) {
- $GLOBALS['content_width'] = apply_filters( 'info_content_width', 280 );
- } else {
- $GLOBALS['content_width'] = apply_filters( 'info_content_width', 1000 );
- }
- }
- add_action( 'after_setup_theme', 'info_content_width', 0 );
上诉方案是用了移动端 280px 宽度,其他终端显示 1000px 宽度。
如果需要视频居中,需要增加css:
- .wp-video{
- margin-left: auto;
- margin-right: auto;
- }