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

Editorial Staff

aThemeArt Editorial Staff prepares and cooks all the content that are published on athemeart.com. They are responsible for all type of web content including blog, social posts, videos, documentation etc.

Leave a Reply

Your email address will not be published. Required fields are marked *

fourteen − 2 =

This site uses Akismet to reduce spam. Learn how your comment data is processed.

NEW FREE THEME! BCF IS HERE GET FREE THEME