If you upload images via the WordPress image uploader and insert it into your post, it will include the image width and height attribute in the html <img> tag. Here’s what it will look like.
<img src="path/to/your/image" width="123" height="456" class="aligncenter size-full" alt="" title="">
In most cases, this is absolutely alright. However, if you are using a responsive theme or are dealing with responsive web design, the “width” and “height” attribute will be a major roadblock that you need to get rid of.
Here’s how you can do it.
1. Open your theme’s functions.php file.
2. Copy and paste the following code:
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; }
3. Save the changes.
That’s it. Next time when you insert image into the post via the WP image uploader, the width and height attribute will no longer be there.
Pingback: How to Remove the Width and Height Attributes From WP Image Uploader
Pingback: How to Remove the Width and Height Attributes From WP Image Uploader | Wordpress Webdesigner
Pingback: Eliminar los atributos de ancho y alto del cargador de archivos WordPress | Ayuda WordPress
Pingback: Eliminar los atributos de ancho y alto del cargador de archivos WordPress | Tecnologia, Desarrollo Web, Posicionamiento Web SEO
Pingback: Eliminar los atributos de ancho y alto del cargador de archivos WordPress | Ayuda
Pingback: 15+ Useful and Fresh Wordpress Hacks / Snippets | gonzoblog.nl
Pingback: How to Remove the Width and Height Attributes From WP Image Uploader - Premium Accounts Info | Premium Accounts Info
Pingback: How to Remove the Width and Height Attributes From WP Image Uploader - Premium Accounts Infro | Premium Accounts Infro
Pingback: How To Remove The Height And Width Attributes In WP Image Uploader | Blogfreakz - Web Design and Web Development resources
Pingback: How To Remove The Height And Width Attributes In WP Image Uploader
Pingback: How to Remove the Width and Height Attributes From WP Image Uploader | Software City
Pingback: How to Remove the Width and Height Attributes From WP Image Uploader | Cheap Website
Pingback: 如何去除WordPress图片上传器中的“Width”和“Height”属性?
Pingback: 10 Useful WordPress Hacks And WordPress Functions - WPShock
Pingback: 10 More Useful WordPress Code Snippets For Your Blog | pixelpush design
Pingback: 10 More Useful WordPress Code Snippets For Your Blog | Indoor Digital Billboards
Pingback: 10 More Useful WordPress Code Snippets For Your Blog « Web Express Way
Pingback: Removing Dimensions From Uploaded Images In Wordpress | Wordpress PhD
Pingback: 10 More Useful Wordpress Code Snippets For Your Blog | Design Inspiration
Pingback: Полезные функции для WordPress блога #3
Pingback: Remove Width and Height Attributes from wordpress content area - WordPress | Joomla | Magento Developer