• Resolved derElch

    (@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
    [/caption]

    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)
  • Thread Starter derElch

    (@derelch)

    okey now i found a better script on this website:

    http://brianswebdesign.com/blog/wordpress/rebuilding-image-tags-when-adding-media

    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>
    Description[/caption]

    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.