脚本宝典收集整理的这篇文章主要介绍了php – WordPress 3.9.x – 从图元素中删除内联宽度,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
add_theme_support( 'htML5',array( 'seArch-form','comment-form','comment-list','gallery','caption' ) );
这很棒.但由于某些原因,wordpress为图元素添加了宽度的内联样式,这会阻止整个单元的响应.那不是很好.我想在functions.PHP中添加一些代码,告诉wordpress不要包含内联宽度.
在media.PHP文件中,我找到了解决我的问题的标题短代码:
$output = apply_filters( 'img_caption_shortcode','',$attr,$content ); if ( $output != '' ) return $output; $atts = shortcode_atts( array( 'id' => '','align' => 'alignnone','width' => '','caption' => '','class' => '',),'caption' ); $atts['width'] = (int) $atts['width']; if ( $atts['width'] < 1 || empty( $atts['caption'] ) ) return $content; if ( ! empty( $atts['id'] ) ) $atts['id'] = 'id="' . esc_attr( $atts['id'] ) . '" '; $class = trim( 'wp-caption ' . $atts['align'] . ' ' . $atts['class'] ); if ( current_theme_supports( 'html5','caption' ) ) { return '<figure ' . $atts['id'] . 'style="width: ' . (int) $atts['width'] . 'px;" class="' . esc_attr( $class ) . '">' . do_shortcode( $content ) . '<figcaption class="wp-caption-text">' . $atts['caption'] . '</figcaption></figure>'; }
任何想法如何从图元素中删除内联样式宽度?
以上是脚本宝典为你收集整理的php – WordPress 3.9.x – 从图元素中删除内联宽度全部内容,希望文章能够帮你解决php – WordPress 3.9.x – 从图元素中删除内联宽度所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。