Remove WordPress image width and height


There are many instances where we would like to ignore the WordPress image defined width and height. To remove those attributes from WordPress image simply add the following snippet to your theme’s functions.php file.

* Removes the explicit width and height from images inserted using WordPress.
function ms_remove_width_attribute( $html )
$html = preg_replace( '/(width|height)="d*"s/', "", $html );
return $html;
add_filter( 'post_thumbnail_html', 'ms_remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'ms_remove_width_attribute', 10 );

Not using WordPress? Try it out today. It’s available here and totally free and open source.

Let’s talk about code, beer, and gaming.


Long after the retirement of I’ve come to the conclusion that the time for blogging has come again. I hope to provide insight into the world of front-end development along with the occasional beer review and musings about gaming. You’ll see the site change looks during the first few weeks as I try to find a theme that fits my needs. I hope you enjoy my posts and feel free to share them with your friends across the web. Enjoy.