How to regenerate WordPress image thumbnails using WP-CLI

September 16, 2024 / WordPress

Over time, when you change your theme or modify image settings, you may need to regenerate thumbnails for your WordPress site. WP-CLI makes this process quick and easy.

Prerequisites:

  1. SSH access to your server.
  2. WP-CLI installed.

Follow steps:

  1. Connect to Your Server via SSH.
  2. Open your terminal and connect to the server:
    ssh username@your-server-ip
  3. Navigate to the WordPress installation directory:
    cd /path/to/wordpress
  4. Run the Regenerate Thumbnails Command using the below command to regenerate all thumbnails:
    wp media regenerate

    This command will process all images in the media library. It will regenerate thumbnails based on the sizes defined in your settings.

  5. Additional Options
    1. To regenerate only missing thumbnails:
      wp media regenerate –only-missing
    2. Skip confirmation prompts by using:
      wp media regenerate –yes
    3. To regenerate thumbnails for specific image :
      wp media regenerate <image_id>
  6. After the process is complete, visit your site to check if the images have been properly regenerated.

This way, you can regenerate WordPress image thumbnails using WP-CLI.

For more help, contact our support staff.