remove default image sizes from wordpress theme

remove default image sizes from wordpress theme

If you want to disable or remove default image sizes from wordpress theme. Than use code in them file. wordpress creates more than five images while upload.

remove default image sizes from wordpress theme

Every custom wordpress theme has their different thumbnail sizes defined. When we upload any image to wordpress,  By default wordpress create four resized images. Means when we upload image, wordpress upload five images on server. Which is not necessary and unwanted. If your theme added, custom thumbnail sizes then it create more than five images and upload on server.

Tip: Whenever you change wordpress theme than regenerate thumbnails in wordpress website.

Use following code in functions.php file.


// Set default thumbnail size
set_post_thumbnail_size( 150, 150 );
function wpapi_filter_image_sizes( $sizes) {
unset( $sizes['medium']);
unset( $sizes['large']);
return $sizes;
}
add_filter('intermediate_image_sizes_advanced', 'wpapi_filter_image_sizes');

We used above code in our wordpress theme. Now while image upload, we are storing only three images on server. which saves the disk space.

If you want to remove unwanted image sizes from wordpress theme. Sometime you need the original and thumbanil image only. But many wordpress themes creates the multiple image version in your site which is not useful. Although it is possible to prevent the creation of default image sizes by changing their dimension settings to ’0′ in Dashboard > Settings > Media, these image sizes will still appear in the list of sizes in the Media Uploader.

Why use above method in wordpress theme

Due to custom thumbnail sizes your server images data will always increase. Some image sizes are not important for bloggers and website. So why to create unwanted images and store on server.

remove default image sizes from wordpress theme
remove default image sizes from wordpress theme

You can always full sized image in website. Just fixing image sizes use following CSS code.

[viral-lock message=”Solution code is Hidden! It’s Visible for Users who Liked/Shared This article on Facebook or Twitter or Google+. Like or Tweet this article to reveal the content.”]


img{max-height:100% !important;max-width:100% !important}

[/viral-lock]

If you use above code in style.css file than your wordpress UI will not break.

Published by

Purab

I am Purab from India, Software development is my profession and teaching is my passion. Programmers blog dedicated to the JAVA, Python, PHP, DevOps and Opensource Frameworks. Purab's Github Repo Youtube Chanel Video Tutorials Connect to on LinkedIn

Leave a Reply

Your email address will not be published.