How to remove image dimension attributes in WordPress

Just a quick snippet. May come handy on responsive layouts.


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;
}

Source. More on the subject.

Club-Mate, the beverage → club-mate.fi