Responsive Web Design Tip: Remove Height & Width from Images in WordPress

Facebook
Twitter

Whenever we build a custom WordPress website and need to make it responsive, we remove the height and width from images inserted into the post content so that they’ll play nicely in a responsive layout.

// Remove height/width attributes on images so they can be responsive
add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 );
add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 );

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

This is just one of the many customizations we make to the WordPress system to get it ready for a fully responsive web design experience.

Let's Talk
We can't wait to hear about your project.
Web & Logo Design Blog

© 2024 Brian Joseph Studios LLC. All rights reserved

Facebook | Twitter | Instagram | Web Design Naples | Web Design Fort Myers | Logo Design Fort Myers | Logo Design Naples | LinkedIn

Fort Myers - (239) 989 3306 | Naples - (239) 280-1294

Google Business Listing - Brian Joseph Studios - Naples Web Design Company