We are Red Bridge Internet, local San Francisco WordPress Developers and WordPress Consultants in San Francisco. We're the ones you have been searching for. Request a Project Quote or call us at 415.857.5745.

Remove IMG height and width attributes with jQuery

You’ll sometimes want to remove the height and width attributes from an image tag. You’ll come across this a lot while working with WordPress content, in which case embeded images are given height and width attributes. A simple one liner of jQuery will allow you to remove the height and width from IMG tags:

$(“img”).removeAttr(“height width”);

Of course the line above will remove height and width from ALL images within your document. You’ll want to better specify the image by including it’s parent container or class.

jQuery’s “removeAttr” will come in handy for other things such as iframes, etc..

Resources

 

Leave a Reply