WordPress automatically adds the width and height attributes to shortcode images.
How to delete these attributes? Something like this but for output.
WordPress automatically adds the width and height attributes to shortcode images.
How to delete these attributes? Something like this but for output.
I can think of a couple of options:
Create a new shortcode, e.g. my_gallery. You can copy the code in
wp-includes/media.php
. Look for the code staring with
add_shortcode('gallery', 'gallery_shortcode');
and then the actual
function. Rename / modify as needed. The actual img link is within
the $link
variable
Use something like this (untested), which should work but might
strip-out all width/height from any link.
_
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;
}