Can I optimize with WP-CLI?
1 min read · Last updated July 2026
Yes. SlashImage adds a wp slashimage command with four subcommands - status, optimize, restore, and cancel - so you can run and check optimization from the shell instead of the browser.
Why use the command line
The Bulk Optimize page is the easy choice for most sites. Reach for WP-CLI when the browser run is a poor fit:
- No request timeout.
wp slashimage optimizeruns in one long-lived process, so it is not bounded by the PHP-FPM or proxy request timeout that limits the browser bulk path. This is its main advantage for very large libraries. - No open tab. The run does not depend on a browser tab staying open.
- Works without WP-Cron. On hosts where WP-Cron is disabled, the command drives the work itself, so it runs where the background queue would otherwise stall.
Requirements
- WP-CLI installed and able to reach your site, usually over SSH to your host.
- SlashImage 1.1.0 or later. Your installed version is shown on the Plugins page.
- An API key for
optimize. Therestoreandcancelcommands work without one.
Settings come from the admin
There are no per-run flags for compression mode, WebP, AVIF, or backups. The commands read those from your saved settings. Change them at Media > SlashImage on the Settings tab first, then run the command.
See also
Was this helpful?