Remove the Width and Height Added to WordPress Images

Posted on 17th September, 2015 240 Comments

When you’re making a site responsive you don’t want images to have a set width and height, so to remove these from your them you will…

Add this to your functions.php

add_filter( 'post_thumbnail_html', 'remove_width_attribute', 10 );
add_filter( 'image_send_to_editor', 'remove_width_attribute', 10 );

function remove_width_attribute( $html ) {
   $html = preg_replace( '/(width|height)="\d*"\s/', "", $html );
   return $html;


To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]


21st, Oct, 20

to concussive entente that, postinjury pathophysiology, and narrow of treatment. [url=]cheap cialis uk online[/url] rare table in sizeable burns, which can emerge rapidly and.


21st, Oct, 20

Szmaac zlxpju online buy cialis generic tadalafil [url=]cialis online prescription[/url] of Pyridoxine’s canada drugs online survey deficiency is Ш° ر—cialis online.


31st, Oct, 20

erectile restoration centers llc [url=]erectile dysfunction pills[/url] reviews of erectile dysfunction treatment


05th, Nov, 20

will erectile dysfunction go away [url=]erectile dysfunction remedies[/url] erectile reverser


08th, Nov, 20

[url=]Das Beziehungs-Mandala[/url]

[url=]Superbike Italia – Dicembre 2016]

[url=]Hyde, Jekyll, Me[/url]

[url=]Dracula 2000]

free porn videos

24th, Nov, 20

I’m amazed, I have to admit. Rarely do I encounter a blog that’s equally educative and entertaining, and without a doubt, you have hit the nail on the head.

The issue is something that too few people are speaking intelligently about.
Now i’m very happy I came across this during my search for something relating to this.


03rd, Dec, 20

viagra over the counter usa 2020 viagra canadian online pharmacy viagra

basics electrical contractors san diego

04th, Dec, 20

I in addition to my buddies were actually going through the excellent things located on the website then then I got a horrible feeling I had not expressed respect to you for those tips. All of the young men ended up absolutely excited to see them and have actually been making the most of them. I appreciate you for being really kind as well as for having certain incredibly good subject areas millions of individuals are really desirous to learn about. My honest regret for not expressing gratitude to you sooner.


22nd, Dec, 20

Taxi moto line
128 Rue la Boétie
75008 Paris
+33 6 51 612 712  

Taxi moto paris

hello!,I like your writing so so much! percentage we
keep up a correspondence more approximately your article on AOL?
I require a specialist on this house to resolve my problem.
Maybe that’s you! Having a look forward to peer you.

Mandi Kizzia

03rd, Jan, 21

Wonderful beat ! I would like to apprentice while you amend your website, how can i subscribe for a blog site? The account aided me a acceptable deal. I had been a little bit acquainted of this your broadcast provided bright clear idea|


05th, Jan, 21

Its like you read my mind! You appear to know so much about this, like you wrote the book in it or something. I think that you could do with some pics to drive the message home a bit, but other than that, this is fantastic blog. An excellent read. I’ll definitely be back.


10th, Jan, 21

Good day! This is my 1st comment here so I just wanted to give a quick shout out and say I genuinely enjoy reading your articles. Can you recommend any other blogs/websites/forums that deal with the same subjects? Thanks a ton!


15th, Jan, 21

Great work! This is the type of information that are meant to be shared across the web. Disgrace on the seek engines for now not positioning this submit higher! Come on over and talk over with my web site . Thank you =)


19th, Jan, 21

free cialis medication for providers buy cialis zolktjuh cialis coupon code
cialis tadalafil 20 mg


20th, Jan, 21

Good write-up, I’m normal visitor of one’s website, maintain up the excellent operate, and It is going to be a regular visitor for a lengthy time.

windows activator kmsauto

20th, Jan, 21

Hello! I could have sworn I’ve been to this site before but after browsing through some of the post I realized it’s new to me. Anyhow, I’m definitely happy I found it and I’ll be bookmarking and checking back often!|

Leave a Comment

To preserve code added to a comment you can wrap your code in short tags
by using [square brackets]:

  1. PHP use - [php] <?php code here ?> [/php]
  2. CSS use - [css] #code-here {} [/css]
  3. HTML use - [html] <div> code here </div> [/html]
  4. JS use - [js] $(".codeHere") [/js]