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.

add different background image to each wordpress posts

WordPress tutorial, add different background image to each wordpress posts. You can change the background images for each wordpress post or change color.  you can change the background color also. Some times this can be doable through CSS also. But here I am going to give you very simple technique.

add different background image to each wordpress posts

Following code you just need to place in your single.php file.

 


if(is_single('17')){
// When Post 17 (ID) is being displayed.

echo "<style>
body{
background: #000 url(images/bgbody.jpg) top center no-repeat;
}</style>";
}

This way you can add the different background image to each wordperss post.

add different background image to each wordpress posts
add different background image to each wordpress posts