WPDev.one
SSH Access
Bash / Shell

Efficiently Regenerate Thumbnails via CLI

Avoid PHP timeouts and memory errors by processing image resizing directly on the server using WP-CLI. Ideal for large media libraries.

Terminal
// Code goes here

Expected Output

user@server:~/public_html$ wp media regenerate --yes
Found 3 images to regenerate.
1/3 Regenerated "hero-background" (ID 1402).
2/3 Regenerated "logo-transparent" (ID 1403).
3/3 Regenerated "team-photo" (ID 1404).
Success: Regenerated 3 images.
user@server:~/public_html$

Useful Flags

--yes

Skip Confirmation

Automatically answer "yes" to the confirmation prompt. Essential for automated scripts or cron jobs.

--only-missing

Optimize Processing

Only regenerate thumbnails for images that are missing sizes. Skips images that are already correct. Great for fixing broken imports.

--image_size=medium

Target Specific Size

Only regenerate a specific image size (e.g., 'thumbnail', 'medium', 'large'). Saves CPU time if you just added a new custom size.

Did this command save your day?

Verify this solution for the community.