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

/*
 * REMOVE WIDTH AND HEIGHT ON IMAGES
 *************************************************************/
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;
}

Comments

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]

JamesVen

21st, Oct, 20

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

JamesVen

21st, Oct, 20

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

RobertBAR

31st, Oct, 20

erectile restoration centers llc [url=http://erectiledysfunctionpillscvs.com/#]erectile dysfunction pills[/url] reviews of erectile dysfunction treatment

RobertBAR

05th, Nov, 20

will erectile dysfunction go away [url=http://erectiledysfunctionpillscvs.com/#]erectile dysfunction remedies[/url] erectile reverser

Stevewah

08th, Nov, 20

[url=https://sittindonesia.org/d6967fe9748d6dc60a6682f497bcfd1c/book/1603776879-9783842300538]Das Beziehungs-Mandala[/url]

[url=https://serpillo.it/fc96fad52c0d859b1f88f6622317530d/magazine/superbike-italia-dicembre-2016]Superbike Italia – Dicembre 2016]

[url=https://mayxaydungsg.com/en/b2f7242ec1e43289269a9e92c73be0ae/stream/61890-1602555912/2015]Hyde, Jekyll, Me[/url]

[url=https://alufiero.it/en/f4e82d07710d7fc5bb4b7ba00308a0ae/stream/10577-1603626343/2000]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.

AngeloTef

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.

hey

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|

vreyrolinomit

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.

vreyrolinomit

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!

zortilonrel

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 =)

Jamesstaro

19th, Jan, 21

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

vreyrolinomit

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]