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.
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
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.