60Web60

Regenerating media thumbnails with WP-CLI

WP-CLI2 min read·

When you change your WordPress theme, the new theme may require different image sizes to what the old theme used. Images uploaded before the theme switch will not automatically generate the new sizes, which can cause thumbnails to look wrong or appear missing. The wp media regenerate command rebuilds all thumbnail sizes for your existing images.

When to use this command

  • After switching to a new theme
  • After installing a plugin that adds new image sizes
  • If images on your site look stretched, cropped incorrectly, or are showing as broken thumbnails

Command reference

CommandWhat it does
wp media regenerateAsks for confirmation then regenerates all thumbnail sizes for all images
wp media regenerate --yesRegenerates all thumbnails without asking for confirmation
wp media regenerate <id>Regenerates thumbnails for a specific image by its attachment ID
wp media regenerate --only-missingOnly generates thumbnail sizes that are missing, skipping existing ones (faster)

Warning about large media libraries

This command can take a long time on sites with many images. The terminal session must stay open during the process. For very large libraries, it may time out. Contact support if this happens.

Need help?

If you have questions about regenerating media, visit our support page or email hello@smarthost.ie.

Frequently asked questions

How long will wp media regenerate take?

It depends on how many images your site has. A site with 50 images will finish in seconds. A site with thousands may take many minutes. Keep the terminal open until it completes.

Will regenerating thumbnails delete my original images?

No. Originals are never touched. Only the thumbnail versions (smaller sized copies) are rebuilt.

What is the --only-missing flag for?

If you have already regenerated some thumbnails and only want to fill in the ones that are missing (for example, for a new image size added by a plugin), --only-missing is much faster because it skips images that already have all their sizes.

Last updated: 25 March 2026