WordPress 修改wp-video标签自适应方案

2021年11月10日15:32:55 发表评论
微信搜一搜 ts小陈

WordPress video标签是插入视频时,自动加载了播放器而生成的标签,这个标签会根据 content_width 设置的宽度而生成视频宽度。

  1. function info_content_width() {
  2.     if( wp_is_mobile() ) {
  3.         $GLOBALS['content_width'] = apply_filters( 'info_content_width', 280 );
  4.     } else {
  5.         $GLOBALS['content_width'] = apply_filters( 'info_content_width', 1000 );
  6.     }
  7. }
  8. add_action( 'after_setup_theme', 'info_content_width', 0 );

上诉方案是用了移动端 280px 宽度,其他终端显示 1000px 宽度。

如果需要视频居中,需要增加css:

  1. .wp-video{
  2.     margin-leftauto;
  3.     margin-rightauto;
  4. }

WordPress 修改wp-video标签自适应方案
 

 

小陈号卡
ts小陈

发表评论(不允许含有网址!)

:?: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :cry: :mrgreen: :neutral: :razz:

已登录用户不需要填写以下内容