WordPress会自动将宽度和高度属性添加到[库]快捷码图像中。
如何删除这些属性?某物like this 但对于[画廊]输出。
WordPress会自动将宽度和高度属性添加到[库]快捷码图像中。
如何删除这些属性?某物like this 但对于[画廊]输出。
我可以想出几个选择:
创建新的快捷码,例如my\\u gallery。您可以在中复制代码wp-includes/media.php
. 查找以下代码add_shortcode(\'gallery\', \'gallery_shortcode\');
然后是实际函数。根据需要重命名/修改。实际img链接位于$link
变量
使用这样的东西(未经测试),应该可以,但可能会被去掉all 任何链接的宽度/高度。
_
add_filter(\'wp_get_attachment_link\', \'remove_img_width_height\', 10, 1);
function remove_img_width_height($html) {
$html = preg_replace( \'/(width|height)=\\"\\d*\\"\\s/\', "", $html );
return $html;
}
如果在函数中设置图像大小。php作为“图库”
add_image_size( \'gallery\', 200, 120, true );
您可以删除特定图像大小(如“gallery”)的宽度和高度:add_filter(\'wp_get_attachment_link\', \'remove_img_width_height\', 10, 4);
function remove_img_width_height( $html, $post_id, $post_image_id,$post_thumbnail) {
if ($post_thumbnail==\'gallery\'){
$html = preg_replace( \'/(width|height)=\\"\\d*\\"\\s/\', "", $html );
}
return $html;
}
我有WordPress 3.2.1 我已经创建了一个个人短代码,在我更改Permalink Settings 从…起Default 到Custom Structure.短代码会永久停止工作,而我会返回到Default 背景你好,我今年[生日=“1975-03-25”]岁。我添加了add_shortcode 在我的主题中的函数functions.php.如果我添加新shortcode 到原始WordPress主题Twenty Eleven 在functions.php 文件,工作正常!我的职能。php文件: