Remove Width & Height from Image Inserted Using Media Uploader

When you insert an image from the media uploader the image code and url is inserted into the HTML are, the image code also contains width and height attribute.

If by any chance you don’t want to display the width & height attribute in the generated image code, this code will be useful. Put the codes in your functions.php

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

Inspire us with your love!

Editorial Staff

aThemeArt editorial staff provides and makes all the content that is published on In addition, they are responsible for all web content types, including blogs, social posts, videos, documentation, etc.

You can check also