Skip to main content
Agency Program Hosting from 10% off. A dedicated account manager. Priority support. Built for growing agencies. Hosting from 10% off, a dedicated account manager and priority support for growing agencies. Speak to the team Join free
AJAX Thumbnail Rebuild icon

AJAX Thumbnail Rebuild

v2.3.0
by junkcoder · 4.8 (90 reviews)

AJAX Thumbnail Rebuild allows you to rebuild all thumbnails at once without script timeouts on your server.

30K+ active installs Updated Nov 20, 2026 Tested to 7.1.5 Requires PHP 7.4
Try Demo Download
Pre-installed Ready in ~10s No card

About AJAX Thumbnail Rebuild

AJAX Thumbnail Rebuild is a plugin that allows you to rebuild the thumbnails on your WordPress site. It rebuilds the thumbnails one by one, avoiding script timeouts, and you can choose which thumbnail sizes to rebuild. It requires JavaScript to be enabled.

Screenshots

AJAX Thumbnail Rebuild screenshot

Frequently asked questions

What is AJAX Thumbnail Rebuild?
AJAX Thumbnail Rebuild is a plugin that allows you to rebuild all thumbnails on your site.
Why would you want to rebuild your thumbnails?
You may want to rebuild your thumbnails when you change the size of thumbnails to fit the design of your website.
How does AJAX Thumbnail Rebuild work?
Instead of recreating all thumbnails at once, they are rebuilt one after another to prevent script timeouts.
Can you select specific thumbnail sizes to rebuild?
Yes, you can select the thumbnail sizes you want to rebuild, so you don't have to recreate all images if you've only changed one thumbnail size.
Is JavaScript required for this plugin?
Yes, this plugin requires JavaScript to be enabled.

Changelog

2.3.0

  • New tab Largest images: the heaviest images that still need optimising, heaviest first. An image weighs what optimising would work on – the uploaded file, its sizes, and the untouched original where the settings say to optimise that too – and images already optimised at the current settings are left out unless asked for. “Optimise selected” opens the Rebuild tab with them, heaviest first, so a Stop or a spent service quota halfway still leaves the heaviest done.
  • New WP-CLI commands: wp atr largest lists the heaviest images that still need optimising, and wp atr optimize optimises the images given, the heaviest few with --largest, or every image that still needs it, heaviest first. It says before starting which optimisers the server has and, where TinyPNG or ShortPixel is set up, how many images will be sent there; --dry-run stops there.
  • GIFs are optimised. gifsicle was listed among the optimisers all along but never ran on anything, because GIF was missing from the formats the optimiser works on. A GIF goes to gifsicle, or to ShortPixel where that is set up, and is never written out again through the image editor, which would keep only the first frame of an animation. On a site with gifsicle installed, GIFs are now made smaller – including those earlier versions marked as optimised without touching them. On a server with neither, GIFs are not listed as needing it, since nothing there could shrink them.
  • A selection handed to the Rebuild tab – from the media library or the Largest images tab – is worked through in the order it was handed over, rather than newest first.

2.2.1

  • Nothing is cut while something is only listing the sizes. Advanced Custom Fields hands an image field back as an array of every size the site registers – and a video or audio field the same array for its poster image – and every entry in those lists was answered by cutting the file for it – on a site with ninety-six registered sizes, one image field on one page wrote 240 files and took 29.5 seconds, inside a visitor’s request. Inside that window the full file is returned instead, which is the honest answer while the size does not exist yet; the first time something actually renders one of those sizes it is cut exactly as before. ajax_thumbnail_rebuild_on_demand_while_enumerating puts the old behaviour back.
  • A size the original is too small for is no longer attempted. WordPress does not upscale, so the cut could only fail – but it failed the expensive way, after loading an image editor and reading the file, and again on the next page view for as long as anything asked for that size. It is worked out as arithmetic now, against the file the crop would actually be cut from. An SVG is skipped before any of that, rather than being rasterised once per registered size.
  • A size asked for after its record has gone is cut again. The note that keeps one request from cutting the same size twice was never taken down, so once a rebuild or wp media regenerate had rewritten the attachment metadata, anything asking for that size again was served the full file where it had asked for a crop.

2.2.0

  • New setting The untouched original, under Uploads beside the limit: the full size original kept beside a scaled upload is brought down to the limit as well. WordPress cuts the sub sizes from that file and then leaves it alone at whatever it arrived as, which on a photograph from a modern camera is most of what the library weighs. Off by default, and it cannot be undone – the resolution the original was uploaded at is gone, and no size larger than the limit can be cut from it afterwards. New uploads are covered as they arrive; an image already in the library is covered the next time it is rebuilt, and its -scaled copy comes down with it where that was written to an older limit.
  • A size marked as made on demand can be rebuilt again. It was shown ticked off and disabled on the rebuild screen, so a file cut for it stayed as it was however the size changed. It is now rebuilt for the images that already have it and cut for no others, which refreshes what is there without writing the files the setting exists to avoid.

2.1.1

  • Sizes a theme or plugin adds through ajax_thumbnail_rebuild_on_demand_sizes now show up ticked under Made on demand instead of looking switched off, and are greyed out there: unticking one never had any effect, because the filter put it back on the next read.

2.1.0

  • New setting When the work happens, under Optimising: optimising and the WebP and AVIF copies can be queued instead of run on upload, so an upload finishes as soon as the resized copies are written. The queue runs on Action Scheduler where the site has it and on WP-Cron where it does not.
  • New filters ajax_thumbnail_rebuild_background_enabled and ajax_thumbnail_rebuild_use_action_scheduler.

2.0.1

  • New filter ajax_thumbnail_rebuild_serve_copies. Return false to keep writing the WebP and AVIF copies while the front end serves the originals, for a site where a CDN or the server itself hands the copies out.

2.0.0

The whole plugin has been worked through: one 430 line file is now a set of
classes, the browser talks to a REST API of its own instead of admin-ajax, and
the screen is built from the components WordPress itself ships.

The screen:

  • A tab each for rebuilding, the registered sizes, cleanup, and one per group of
    settings, so no page is a wall of fields.
  • Rebuilt out of tabs, list tables, postboxes and notices, with a progress bar,
    a running preview, a Stop button and a list of anything it had to skip.
  • A “Registered sizes” tab listing every image size on the site with its
    dimensions and crop setting.
  • Rebuild only the images whose file name matches a pattern, e.g. banner-*.jpg.
  • Rebuild straight from the media library: a row action for one image, and a
    bulk action that hands the selection to the plugin’s screen, where it runs one
    image at a time.
  • Rebuild, optimise or replace an image from the attachment details, wherever
    they open – the media library, the grid, or the modal inside the post editor –
    without leaving the page you are on.
  • Replace an image by uploading a new file. The attachment keeps its id, its
    title and its address, so every post and product already pointing at it shows
    the new picture; the sizes are cut again and what the old picture left behind
    is deleted. The new file has to be the same kind of image, which is what keeps
    the links working.
  • “Only rebuild featured images” also covers the images in a WooCommerce product
    gallery. A product’s main image is its featured image, so that was already
    included.

New, all off by default:

  • Upload settings. How hard WordPress compresses the copies it writes, and
    how large an image may stay before it is scaled down – both of which WordPress
    decides for you and gives no screen for. Set the size to 0 to keep uploads
    exactly as they arrive.
  • Optimising. Makes files that are already the right size smaller, using the
    optimisers installed on the server – jpegoptim, optipng, gifsicle, and
    pngquant when a site allows lossy PNG. They re-pack a file rather than
    re-encode it, which is where the saving is; where none is installed the plugin
    says so and falls back to re-encoding with PHP’s own library. Nothing is
    resized, a file is replaced only when the new one is genuinely smaller, and
    the untouched original beside a scaled upload is left alone unless a site asks
    for it. Where a host has no optimiser and will not run one, TinyPNG or
    ShortPixel can do the same job over their API. Runs on upload, over the
    library, or on single images from the media library.
  • AVIF and WebP copies. Every image WordPress generates gets a copy written
    next to it in either format, and the front end serves them through a picture
    element – AVIF first, WebP after it, the original as the fallback – which
    works behind a page cache. Each format has a switch and a quality of its own,
    a copy that would be larger than the original is discarded, and the copies are
    deleted with the attachment. AVIF is the smaller of the two and the slower to
    encode; where the server’s image library cannot write it, the screen says so
    and the WebP copies go on being served.
  • Image proxy. Front end image URLs can be served through wsrv.nl, which
    resizes and re-encodes on the fly and serves the result from a CDN. Your own
    files are never touched.
  • Sizes on demand. An upload keeps only its own file and each size is cut
    the first time something asks for it – either for every size, or for single
    sizes ticked off one by one, which a rebuild then skips.
  • Cleanup. Finds the resized files nothing points at any more – the ones
    left behind every time an image size changes – and deletes them after you have
    looked at the list. The scan only reads; a file that is an attachment of its
    own, or an AVIF or WebP copy of a file still in use, is never listed.

Fixed:

  • Rebuilding no longer throws away the rest of the attachment metadata.
    original_image and filesize survive, so WordPress can still find and
    delete the untouched upload (props @toolshedlabs-hash).
  • Sub sizes are cut from the original image rather than from the “-scaled” copy,
    which used to leave a duplicate set of files behind.
  • Selecting a subset of sizes rebuilt every size anyway.
  • Sizes registered through the intermediate_image_sizes_advanced filter are
    picked up; the filter now receives the metadata and attachment id core passes
    it.
  • “Toggle all” checks or clears every size instead of inverting each one.
  • The button on a single attachment works when several attachments are on
    screen; it no longer prints a copy of the whole script per image.
  • An image whose file is missing or unreadable is skipped and listed, instead of
    stalling the run.
  • PHP 8.4 compatible; undefined variables, unchecked getimagesize() results
    and unescaped output cleaned up throughout.

1.14

  • Fix security issues (props @patchstack)
  • Fix Github link (props @Julix91 @garretthyder)
  • Fix crop-settings for additional sizes (props @karlkowald)

1.2.2

  • Compatibility with PHP 7.2 (props @thomas-gordon)
  • Implemented throttling and retries for image regeneration (props @da2x)

1.2.1

1.2

  • Compatibility with PHP7

1.12

  • FIX: An issue where rebuilding thumbnails in the media gallery
    would not work

1.11

  • FIX: An issue where the plugin would sometimes break the media gallery.

1.10

  • NEW: Rebuild thumbnails of single images on the media attachment page.

1.09

  • NEW: Checkboxes can be activated by clicking on text.

1.08

  • NEW: Slovak translation, provided by Branco Radenovich.

1.07

  • FIX: Don’t create metadata with empty size when original image is smaller
    than the target size.

1.06

  • FIX: Don’t forget metadata for sizes that aren’t rebuilt.
  • FIX: Option to only rebuild featured images should now work correctly.
  • FIX: Don’t fail if there are no attachments.
  • NEW: It’s now possible to toggle all selected sizes.
  • NEW: Added translation: German.

1.05

  • Add option to only rebuild post thumbnails (featured images)

1.04

  • Tested with WordPress 3.2

1.03

  • Fixed: Show correct height value for thumbnails.

1.02

  • You can now select which thumbnail sizes you want to rebuild. Thanks to Nicolas Juen!

1.01

  • Tested with WordPress 3.0

1.0

  • Initial release

Try other plugins