Technote

Performance optimization Practical

Series Images that do not slow the site down Part 3 of 8

The image sizes WordPress creates for you

One upload produces several files. Any of them never used on screen clutters both your disk and your srcset at the same time.

The media library shows one image, but open the uploads folder on the server and you find several files sharing a name with dimensions appended. WordPress creates a copy for every registered size at upload time.

Why generate them in advance?

Resizing on every request would put the server to work each time. Generating up front means a visitor receives a file that is already prepared, and — more importantly — the responsive image candidates covered in the next part are assembled from exactly these copies. They are raw material, not waste.

Sizes get registered in two places: the core defaults (thumbnail, medium, large and so on) and whatever the theme and plugins add. The second group is where trouble accumulates — change theme and the files generated for the old theme’s sizes remain on disk, unused by the new one.

Where the copies of one upload come from — the lower rows are the easiest to forget

Two costs of a size nobody uses

The first is disk and backups. On a site with several thousand images, one unused size means several thousand files. Backup windows and migration time grow with them.

The second is less discussed and more irritating. When WordPress builds the responsive candidate list, it draws those candidates from the copies that exist. A pile of awkward sizes unrelated to your actual layout makes the candidate list messy, and what the browser ends up choosing drifts away from what you intended.

The order to clean up in

Four steps to tidy image sizes — keep the order and the work stays reversible

Start by listing what is registered right now. Then check whether each size is actually requested by a template. Drop the registrations nobody calls, and only then regenerate the copies for existing images against the new set.

The order matters. Delete files before removing registrations and you lose the list of what needs regenerating. And at every stage, back up the uploads folder together with the database first — if the state is not reversible, the cleanup does not start.

This work connects to other articles in the performance archive, and if you would rather hand over the cleanup and regeneration as one job including the server side, it is covered by our optimization program. The procedure itself is published on the process page.

Next part

With the raw material tidy, we turn to what consumes it. The next part is srcset and sizes — the mechanism that stops a phone downloading a desktop-sized image.

More on this topic

All technotes

Performance optimization Practical

Who pays for the milliseconds a tag adds?

A tracking script does not stop at downloading. While it is parsed and executed the main thread is busy, and a busy page ignores fingers. That cost is…

Marketers 5 min read

Performance optimization Practical

The object cache: what Redis actually removes

Repeated identical lookups disappear. One slow query does not. Miss that distinction and you will wire up Redis and then ask why nothing got faster.

Developers 7 min read

Performance optimization Practical

This is how a landing page gets heavy

Nobody decides to make a landing page heavy. It accumulates: one addition per campaign, and nothing ever removed when the campaign ends.

Marketers 6 min read

₩270,000 · Join the program