How to bulk optimise an old WordPress media library without breaking it

An old media library is full of originals nobody ever shrank. You want them smaller, and you do not want a single broken image on the live site. This is the order that keeps that promise: back up, try 50, run the rest, read what was skipped, check the pages, know how to undo.

The steps use The Image Optimizer (TIO), because that is the tool we can describe exactly. The backup, sample and checking steps apply to any bulk optimiser.

Before you start: what a bulk run changes

Know this first, because it decides how careful you need to be.

  • Bulk Optimize overwrites your original files in place. Neither the plugin nor the TIO service keeps a copy. The plugin makes you tick a box that says so before it lets you start. A backup is the only way back.

  • File formats and URLs stay as they are. A JPG stays a JPG and a PNG stays a PNG, so links in posts and pages keep working. WebP and AVIF copies are created next to the original and offered to browsers through a <picture> tag. HEIC originals are the exception to “overwritten”: they are kept exactly as they are, and only get WebP and AVIF copies.

  • Thumbnails are regenerated on your server from the optimised original. It costs one credit per image, not one per thumbnail size.

  • The run needs the page open. Your browser fires each step, so nothing happens while the tab is closed. Your progress is saved on the server. When you open the Bulk Optimize page again, the run carries on by itself from where it stopped.

Step 1: take a backup you have tested

You need both parts of a site: the database and the wp-content/uploads folder. Only the uploads folder changes in a bulk run, but the database holds the record of every image size, so a restore that has one without the other is a mess.

  1. Take a full backup with your host's tool or a backup plugin.

  2. Download or confirm where the uploads folder copy is stored.

  3. Check you can restore it. Open the backup and look for a file you know exists, such as wp-content/uploads/2024/03/some-photo.jpg. A backup you have not opened is a hope, not a backup.

If you can, run the first try on a staging copy of the site instead of the live one. Skip that if you do not have one. The sample in step 3 is the safety net.

Step 2: scan, and read the numbers

In your WordPress admin go to Tools, The Image Optimizer, Bulk Optimize and click First, scan your media library.

The scan shows four counts: Unoptimized, Optimized, Skipped and Total. Skipped images are ones it will not send, each with a reason (see the table below). Below the counts it says how many credits this run will use. Once the run starts, the screen switches to a Remaining count.

The Unoptimized number includes images that were compressed by an older version of the plugin and have no WebP or AVIF copies yet. They are picked up again so the copies can be made. Each of these costs one credit, like any other image, unless TIO cannot make the file any smaller, in which case it costs nothing. The credit figure on the scan screen counts every image in Unoptimized, so the run may use fewer credits than it shows, never more.

Compare the credit figure with the credits you have left. If you have fewer credits than images, the run stops cleanly when the credits run out and tells you how many it did. Top up and click Resume. Images already done are skipped, so you only pay for what is left. Pricing lists what a credit costs.

Step 3: run a sample of 50

Do not start the full run first. Run enough to learn what your library does, then stop.

  1. Tick the box that confirms you have a backup.

  2. Click Start optimizing.

  3. Watch the counter. When it reaches about 50 done, click Pause.

The run takes the newest uploads first. That suits a sample, because recent images are the ones people see. If your newest uploads are not typical of the library (say, a recent switch from large to small photos), pick a few older pages and check those as well.

Now check the result before you go on.

  1. In Media, Library (list view), look at the Optimized column. Optimised images show a percentage saving, and may show a “Next-gen: AVIF, WEBP” label under it.

  2. Open three or four pages that use those images. Look for blurry images, wrong crops and missing pictures. Check the biggest hero image and a small thumbnail separately.

  3. Open one optimised image in the Media Library and compare its file size with the original in your backup.

If anything looks wrong, stop here and use the undo steps at the end.

Step 4: run the rest

Click Resume. Keep the tab open while the run is active. You can pause and resume whenever you like. You can leave the run overnight by keeping the tab open on a computer that will not sleep.

If the screen says the run stopped early because of credits or a connection, top up or reconnect and click Resume. The run carries on from where it stopped.

What each skip reason means

TIO will not waste a credit on an image it cannot improve. In the Media Library, a skipped image shows a “Skipped:” label with one of these reasons. Each reason, and the “-0%” case, is explained in more detail in why TIO skipped my image.

Label in the Media Library
What it means
What to do
Too small to compress
What it meansThe file is under 10 KB. Compression would save next to nothing.
What to doNothing. These are icons and tiny graphics.
Unsupported format
What it meansNot a JPEG, PNG, WebP or HEIC. GIF is the usual one. SVG and AVIF files also land here.
What to doNothing for SVG and AVIF. Re-export a GIF as a video or a static image yourself if its size matters.
File missing on server
What it meansWordPress lists the image, but the file is not in the uploads folder.
What to doFind out why. Often an old migration. Delete the entry or re-upload the file.
Larger than 100 MB
What it meansOver the size limit.
What to doResize the original on your computer and upload it again.
Failed after retries
What it meansThree attempts in a row failed.
What to doClick Stop on the Bulk Optimize screen (or Dismiss on the “All done” screen). That clears these markers and scans again. Then click Start optimizing.

A sixth case looks like a skip but is not one. If the original is already as small as TIO can get it, the image is counted as done, not skipped, and it costs no credit. In the Media Library its Optimized column shows “-0%”. TIO never replaces an image with a bigger one. It still gets its WebP and AVIF copies where those come out smaller.

A “Skipped” label stays on the image, and a re-scan will not clear it. Only “Failed after retries” can be retried, with Stop or Dismiss as above. Stop also resets the run counters (images done, savings) to zero. The other four labels stay even after Stop, and the plugin has no button to clear them. If you fix the cause, for example by replacing a missing file, upload the image again as a new Media Library item.

Check the front end

Do this after the full run, not only after the sample.

  1. Purge your page cache and any CDN cache. Without this you are looking at old pages.

  2. Open your five busiest pages in a private window. Look for blurry or stretched images, especially hero images and logos.

  3. Open DevTools, go to the Network tab, filter by Img, and reload. Large images should now show as webp or avif in the Type column where the browser supports it. If they do not, see WebP images not showing or not served in WordPress.

  4. Check pages that use sliders, galleries and page builders. These are the ones most likely to print images outside the usual WordPress image calls.

How to undo it

There are two different things here, and the names are easy to mix up.

Restoring the images means restoring your backup. Bulk Optimize does not keep the originals, so put back the uploads folder from the backup you took in step 1. If you restore the uploads folder only, also restore the database from the same backup so that the image records match the files.

The Restore Credit button gives your credit back. It does not bring the original file back. In the Media Library, next to an optimised image, you may see a Restore Credit button with the time left. It is there for 24 hours after the image was optimised, and it returns that credit to your account. The file on your server stays optimised.

So: if you only wanted a credit back, use the button inside 24 hours. If you want the old file back, restore the backup.

When something goes wrong

  • The run seems stuck. Check the tab is still open and the computer is not asleep. Click Pause, then Resume.

  • Images look blurry on some devices. Check the Network tab to see which file is loading. If a WebP or AVIF is coming through at a small size on a big slot, that is a next-gen file issue and not a compression one. See the WebP guide.

  • An image is gone. Check the skip reason first. If the file was missing before the run, it was not caused by the run. Otherwise restore the file from your backup.

Before you run any of this on a site that matters, do step 1. Everything else in this guide can be corrected. A missing backup cannot.