What WP-CLI commands does SlashImage have?
3 min read · Last updated July 2026
SlashImage adds four WP-CLI commands: wp slashimage status, wp slashimage optimize, wp slashimage restore, and wp slashimage cancel. Run them from your site's shell after connecting over SSH.
wp slashimage status
wp slashimage status [--format=<table|json|csv|yaml>]Prints a read-only snapshot and changes nothing. It reports four things: your connection (whether an API key is present and whether it is valid), the queue (how many images are waiting, in progress, done, and failed), the active run (whether an optimize or restore run is going, and how much is left), and your library counts (how many images are optimized, not optimized, excluded, or errored). The default table format is for reading; --format=json, csv, or yaml are there for scripting.
wp slashimage optimize
wp slashimage optimize [<id>...] [--all] [--force]Optimizes images in the foreground with a live progress bar. Pass one or more attachment IDs, or --all for the whole library - not both. Requires an API key. Because it runs in a single process, it is not bound by the request timeout that limits the browser bulk run.
If an optimize run is already going, the command refuses to start rather than clobber it. Clear a stuck run with wp slashimage cancel, then try again.
# Optimize two attachments
wp slashimage optimize 217 218
# Optimize the whole library
wp slashimage optimize --allwp slashimage restore
wp slashimage restore [<id>...] [--all] [--yes]Restores images from their backups. Pass attachment IDs, or --all to restore everything that has a backup. Add --yes to skip the confirmation prompt on --all. No API key is needed, because restore is local. Any image without a backup is skipped with a warning and the run continues.
Restore refuses to run while an optimize run is active. If you see An optimization run is in progress, pause or cancel it on the Bulk Optimize page (or with wp slashimage cancel), then run restore again.
wp slashimage cancel
wp slashimage cancelCancels the active optimize or restore run, drops the images still waiting in the queue, and returns to idle. It is non-destructive: it does not touch your files, your backups, work that already finished, or an image that is mid-process. If nothing is running, it says so and exits cleanly.
Notes
- Exit codes.
0means success, or that the only remaining work was deferred for a later retry.1means the run had failures, or you passed no API key, an invalid key, or bad arguments. Failure counts are scoped to that run, not the whole queue. - Multisite. Target a specific site with WP-CLI's own
--url=<site-url>flag. Without it, commands run against the main site. - Per-command help. Run
wp help slashimage <command>for the full options of any command. - Language. Command output is English only, following WP-CLI's convention.