Today I am going to explain about to remove thumbnail dimensions in WordPress.Main Reason to remove width and height dimensions of the thumbnail is to maintain fluid images in the thumbnail.
Almost every WordPress blog post needs an image! An image will give the readers an prompt idea of what the post is about and the image will grab the visitors attention in as well. WordPress provides a very easy way to add an image to your post, handle default image sizes from admin, also can do the modification to that image and upload a featured image of the post.
When you upload any image in the WordPress, WordPress creates a copy of the image which is internally adjusted, or zoom out or crop and it will display the specific dimension once you display to the front and if you want to remove thumbnail dimensions in WordPress, it is possible in the easiest manner.
From the WordPress 2.9, WordPress Started to create a thumbnail and provides a detailed interface to change the thumbnail dimensions from the admin panel settings.
Here is the example of the_post_thumbnail function
if ( function_exists( 'the_post_thumbnail' ) )
the_post_thumbnail( 'thumbnail' );
This function will display a thumbnail, where the parameter “thumbnail” indicates the size of the thumbnail display. WordPress four preset size, you can use any of the four parameters like Thumbnail, Medium ,Large or Full (original size) to replace the ‘thumbnail’.
How to remove thumbnail dimensions in WordPress?
Let’s check the function which will remove the thumbnail dimensions in WordPress. It is very easy to use the function.You may be wondering about those image sizes.It will take default size of the thumbnail.
// Remove thumbnail width and height dimensions that prevent fluid images in the_thumbnail
function remove_thumbnail_dimensions( $html )
$html = preg_replace( '/(width|height)=\"\d*\"\s/', "", $html );
add_filter('post_thumbnail_html', 'remove_thumbnail_dimensions', 10);
First, make sure your WordPress version 2.9 above then You can add this function into your active theme’s functions.php file and refresh the page you have used an image and see the magic :).It is very easy to use.I wish you fun with experimenting and using this solution.