可以使用“!important”替代内联样式,如下所示:
width: 100px !important;
如果需要PHP修复,请查看以下内容:
http://troychaplin.ca/2012/06/updated-function-fix-inline-style-that-added-image-caption-wordpress-3-4/add_shortcode(\'wp_caption\', \'fixed_img_caption_shortcode\');
add_shortcode(\'caption\', \'fixed_img_caption_shortcode\');
function fixed_img_caption_shortcode($attr, $content = null) {
if ( ! isset( $attr[\'caption\'] ) ) {
if ( preg_match( \'#((?:<a [^>]+>\\s*)?<img [^>]+>(?:\\s*</a>)?)(.*)#is\', $content, $matches ) ) {
$content = $matches[1];
$attr[\'caption\'] = trim( $matches[2] );
}
}
$output = apply_filters(\'img_caption_shortcode\', \'\', $attr, $content);
if ( $output != \'\' )
return $output;
extract(shortcode_atts(array(
\'id\' => \'\',
\'align\' => \'alignnone\',
\'width\' => \'\',
\'caption\' => \'\'
), $attr));
if ( 1 > (int) $width || empty($caption) )
return $content;
if ( $id ) $id = \'id="\' . esc_attr($id) . \'" \';
return \'<div \' . $id . \'class="wp-caption \' . esc_attr($align) . \'" style="width: \' . $width . \'px">\' . do_shortcode( $content ) . \'<p>\' . $caption . \'</p></div>\';
}
或javascript/JQuery:
$(".wp-caption").removeAttr(\'style\');