Support » Plugins » Hacks » removing image width and height

  • Resolved derElch


    hello all together.

    i’m removing the automatic placed width and height information from images, because i want to organize the width of the images by CSS, so my theme can be responsive.

    add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
    add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );
    function remove_thumbnail_dimensions( $html ) {
    	$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
    	return $html;

    the problem is, this code is removing the

    [captio id="XXX"]
    ... caption text

    too and i simply dont want that. how have i to modify tis code that the caption information will still be there?

Viewing 1 replies (of 1 total)
  • okey now i found a better script on this website:

    if i want to include this to my functions.php it wont work right.

    [caption id="XXX" width="XXX" (i know this still isnt removed)]
    < a …>< img src=”XXX” … width=”XXX” height=”XXX”/>< /a>

    I tried to modify the result img-tag to can see differences better, nothing happend, still exactly the same code like before inclunding (and the “preg_replace”).. Any idea?

Viewing 1 replies (of 1 total)
  • The topic ‘removing image width and height’ is closed to new replies.