Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

Situation :

When uploading an image via the media uploader, WP automatically makes at least 3 additional sizes, that comes to 4 images including the original one. Most of the time, the images will be used at most 2 ( 1 thumbnail for the archive page and 1 for within the post itself. )

Problem :

Before long, the site will be bloated with unused images, and that's ok until the time to backup site.

Suppose a new WP site is up and there will be 1 post per day with 1 image per post, for a year, we will have 365 times 4 image files sitting in the upload folder ( 1460 files).

Within 3 years, we will have 4,380 image files all together !!!

Solution :

So how do you handle this ?

share|improve this question
    
Heh. I know photographers who shoot that many (10MB+) photos each week. :-) –  Denis Dec 14 '10 at 12:35
    
That would come to 500MB+/year :) –  coldcoldheart Dec 14 '10 at 14:28

3 Answers 3

Images sizes for the purpose of creating/deleting attachments seem to be retrieved with get_intermediate_image_sizes() function, that isn't documented in Codex (only briefly mentioned in 3.0 release notes).

That function passes result (combined set of default and custom image sizes) through intermediate_image_sizes filter, so you can likely use that hook to disable unwanted sizes.

See source for details.

share|improve this answer
    
Thank you very much, I will check it out, and will report back to this post ( after I actually try it.) Still, I wonder why I've never heard or read about this before, it's as if everybody is busy building up new WP sites and not worry about the overhead when it's time to backup and manage thousands of files a few years later. –  coldcoldheart Dec 14 '10 at 14:39
    
Note that not everyone uses media functionality. I don't myself (writing post with Windows Live Writer that uploads images via FTP). Even without multiple sizes I do have over thousand images by now, no backup issues so far. –  Rarst Dec 14 '10 at 14:47

Another chance to recommend two plugins I created that together will do what you want. Virtual intermediate images will intercept the creation of the intermediate image sizes: they will not be created on disk, but still exist in the metadata array. This makes WordPress think they exist so you can use them like normal images. The companion plugin, On-Demand Resizer will create missing image sizes when they are requested. The first time the image is requested it is created, all subsequent requests will just be served the newly created image.

share|improve this answer

A simple answer is that you can remove 2 unused sizes by enter 0 for their width or height. For example, you need only the small thumbnail 150x150 and full-sized image, so enter 0 for width and height of Medium and Large sizez.

share|improve this answer
    
That's a nice trick! image_make_intermediate_size() indeed skips a size if both the width and the height are zero. –  Jan Fabry Jan 13 '11 at 15:57

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.