The challenge
When we migrated the large WooCommerce site to new hosting, the media layer broke. Featured images failed to load, "can't find image" warnings appeared during regeneration, thumbnail sizes were missing. File counts and attachment records didn't match. Regeneration failed. Permission conflicts between server users caused unlink failures, lock file conflicts and logging errors.
In one affected directory alone, around 5,000 attachment records were out of sync with the files on disk; hundreds of large images exceeded 1–2 MB. This wasn't a simple thumbnail glitch. It was a database-to-filesystem mismatch at scale.
Site-wide, the image library needed attention: PNGs where JPG would do, oversized thumbnails, no consistent strategy. Fixing the broken layer was the first step; making the whole library smaller and faster was the second.