loading

Why WordPress Creates So Many Image Sizes

When you upload an image to WordPress, it automatically generates multiple versions—including sizes like 150x150, 300, 768, and 1024 pixels. On this specific site, the uploads folder holds 124 original files and 387 generated files, totaling 511 files weighing in at 74.6MB. We tracked which of these files were actually requested over a 30-day period using the site's access logs. Out of those, 123 of the 150x150 files were never requested in the entire month. For the 300px wide files, 83 were requested, but they only accounted for 0.6% of the total data sent. Conversely, 120 of the 124 original files were requested, making up 881.9MB (56.6%) of the total image data transferred. The whole point of creating these thumbnails is to reduce the amount of original file data sent, yet on this site, the originals were actually being served the most.

File Count vs. Requests by Image Size

Between midnight on August 23rd and midnight on September 22nd, we analyzed 7,777 requests made to the folder located at /wp-content/uploads/. Of those, 5,192 were requests for files that actually exist. We'll look at the remaining 2,585 requests separately.

Size File Count File Size Files Requested Total Requests Data Transferred Size Per Request
150x150 123 3.2MB 0 0 0 —
300px Wide 123 6.9MB 83 151 9.3MB 61KB
768px Wide 89 18.0MB 86 2,001 482.6MB 241KB
1024px Wide 52 9.0MB 40 566 183.8MB 325KB
Original 124 37.6MB 120 2,474 881.9MB 356KB
Total 511 74.6MB 329 5,192 1,557.6MB 300KB
Image size request bar chart
While 768 width gets the most requests, the original file accounts for the most data transfer at 881.9MB, making up 56.6%.

It's normal that the 150x150 size has zero visitor requests because it's only used in the media library on the admin side. Even so, 123 files totaling 3.2MB are taking up disk space and are included in backups. The 300-width size is listed in the srcset attribute, so it's occasionally picked up by search bots or on smaller screens, but it only got 151 requests. The real traffic load is concentrated on the 768-width and the original sizes. The 768-width size gets the highest number of requests because it's used on the homepage and in listings, and although the original has fewer requests, it's the top contributor to data transfer because a single instance is 356KB.

Two Ways the Original Image Gets Requested

If you look at the referrers for the 2,474 original image requests, you can see where they are being called from.

Page Requesting the Original WordPress/Server Site AI Site
Home Screen (/) 1,224 113
No Referrer 325 260
Post Body (/post-number/) 260 187
List Pages 2+ (Categories, Tags) 59 46

The WordPress/Server Site called the original image 1,224 times from the home screen. This is even though the home screen's post list is set to use a 768-pixel wide file. The reason is related to the width of the featured image uploaded in August. The two most requested original images were PNG files measuring 696x500 and 740x500, uploaded on August 21st. If the width is smaller than 768px, WordPress won't generate the 768px or 1024px files, and the home screen defaults to using the original. These originals were 406KB and 391KB, respectively. Over 30 days, the first file was served 186 times totaling 70.8MB, and the second file was served 162 times totaling 61.0MB. Starting in September, when the featured image was standardized to 1200x630, the 768px file was created, and subsequent home screen requests for posts started using the 768px version.

In the Post Body, the Original is the Default

For the featured image at the top of a post, the theme puts the original in the src attribute and lists 300, 768, and 1024 widths in the srcset. The sizes attribute is set to auto, (max-width: 768px) 100vw, 768px, meaning an image is placed in the 768px slot. However, on screens with a 2x pixel density, it looks for a 1,536px image and then selects the original, which is larger than that. A significant portion of the 447 original requests from the post body come from this path. Similarly, 566 requests for the 1024px width also stem from this srcset. Out of 11 instances of the 1024x538 file, 10 were requested 492 times. Furthermore, 12 of the 52 files available at the 1024px width were never requested, mostly coming from the body graphs. This is because the original width for the graphs is 1100px, giving little reason for the srcset to choose the 1024px option, and one was the featured image of a post that hadn't been published yet.

2,585 Requests for Non-Existent Files

Out of 7,777 requests to the upload folder, 2,585 (33.2%) were for paths that don't actually exist. This breaks down into 1,455 404 errors, 979 redirects from HTTP to HTTPS (301), 79 403 errors, and 51 500 errors.

There are 154 unique non-existent paths. The most common one is the folder itself, /wp-content/uploads/, which accounted for 859 requests, with the rest being PHP files.

Requested Path Count
/wp-content/uploads/ (Folder Listing) 859
/wp-content/uploads/index.php 235
/wp-content/uploads/file1.php 150
/wp-content/uploads/users.php 150
/wp-content/uploads/panel.php 149
/wp-content/uploads/2024/index.php 58
/wp-content/uploads/gravity_forms/.../dfylbgoahqt.php 48

Since the upload folder is a place where files can be written, the scanner is cycling through names to check if any PHP files are hidden in other locations. The fact that file1.php, users.php, and panel.php have nearly identical request counts is because the same scanner is running them as a group. Just like the requests that scanned the .git folder, these are all resulting in 404s right now, and there are no PHP files in this site's upload folder.

For the 859 requests to the folder listing, since Apache doesn't show directory listings, the results were 394 404s, 388 301s, and 77 403s.

182 Files That Were Never Requested

Out of 511 files, 182 (35.6%) haven't been requested in the last 30 days. Of these, 123 are from the 150x150 size, and the remaining 59 are: 40 files at 300px wide, 12 files at 1024px wide, 3 files at 768px wide, and 4 original files.

These files total 7.3MB, which is 9.7% of the total size. If you look at the sets of files attached to an original image, 99 out of 124 sets had both the original and a resized version requested. 21 sets only had the original requested, 2 sets only had a resized version requested, and 2 sets had nothing requested at all. The 21 sets where only the original was requested were all uploaded in July and August, and they all lack the 768px size, only having 150x150 and 300px widths.

This is the same reason why the traffic only dropped by 0.5% when I reduced the number of PNG files in a set of ten, as mentioned in Reducing Ten PNG Files. At that time, I reduced the file size, but what the homepage was actually calling for was the original image, which lacked the necessary resized versions.

Summary of Findings

  • 56.6% of the image data being sent is the original file. For example, the featured image in August was smaller than 768 pixels, so no resized versions were created, and the homepage was using the original. If you re-upload that image at a width of 1200 pixels, the homepage requests will then switch to the 768-pixel version.
  • There are 123 files of size 150x150 that received zero requests. Deleting them won't change anything for visitors, but since the admin media library pulls the original, it's better to disable generation than to delete them.
  • About one-third of the requests to the upload folder are scanners looking for PHP files. If you don't have a rule blocking PHP execution in the upload folder, this log serves as evidence that such a rule should be put in place.

How We Measured This

We analyzed the paths and sizes of 511 files in the upload folder, categorizing them by size using the format -width x height found at the end of the filenames. One of the 124 original files was actually a log file, not an image. Among the four original files that weren't requested, one was that log file. We pulled lines from five access logs containing the path /wp-content/uploads/ and matched them to existing files to count requests, response sizes, referrers, and status codes. The time frame covered was from the first line of the log, August 23rd at 12:01 AM, to the last line, September 22nd at 12:06 AM. The total data sent is the sum of the response sizes in the log; this includes 234 requests with a 206 response and 62 requests with a 304 response. We checked the image widths using the file command, and for the images in the homepage and post content, we used curl to inspect the srcset and sizes attributes. The selection based on screen pixel density isn't recorded in the logs, so we explained it using browser rules.