WPMU DEV is dedicated to supporting advanced users in every possible way. Our Smush API Documentation is an ongoing project. Information about new commands will be added here as it becomes available.

WP-CLI is the command-line interface for WordPress. You can update plugins, configure multisite installations and much more, without using a web browser. Smush has an integration module with WP CLI, which will allow you to simplify a few common tasks.

4.1.1 Scan media library

Link to chapter 1

Command

wp smush scan

Parameters

This command has no parameters.

Examples

Scan the media library of a single site or a multisite. If multisite, results will be returned for the main site and each subsite as separate tables.
wp smush scan

4.1.2 Image optimization

Link to chapter 1

Allows optimizing single images, batch optimization, as well as bulk optimization of the whole media library.

Command

wp smush compress [–type=] [–image=]

Parameters

type
String
Optimize single image, batch or all images. Accepts: all, single, multiple, batch. Default: all.
image
Integer
Attachment IDs to compress. Default: 0 (all). When type=multiple, add IDs as a comma-separated list.

Examples

Smush all images.
wp smush compress

Smush single image with ID = 10.
wp smush compress --type=single --image=10

Smush multiple images with IDs = 10, 15, 216
wp smush compress --type=multiple --image=10,15,216

Smush first 5 images.
wp smush compress --type=batch --image=5

Smush all images on a site with slug blog on a WordPress multisite instance using subdomains.
wp smush compress --url=blog.example.com

Note that the wp smush compress command will respect all current settings in the Smush plugin on the site where the command is run. In other words, if the Super-Smush option is enabled on the site, running this command will super-smush the images.

4.1.3 List unoptimized images

Link to chapter 1

Command

wp smush list [–filter] [count]

filter
String
Optional. Type of media to scan. Accepts all, resmush, unsmushed. Default: all
count
Integer
Limit number of images to get.

Examples

Get all images that need to be optimized.
wp smush list

Get the first 10 images that need to be optimized.
wp smush list 10

Get all images that need to be reoptimized (usually needed after a settings change).
wp smush list --resmush

Get the first 10 images that need to be reoptimized.
wp smush list --resmush 10

Get all images that have never been optimized.
wp smush list --unsmushed

Get the first 10 images that have never been optimized.
wp smush list --unsmushed 10

4.1.4 Restore images

Link to chapter 1

Allows restoring images that have backups (backups need to be enabled via the “Store a copy of my full size images” option in Smush).

Command

wp smush restore [–id=]

Parameters

id
Integer
Attachment ID to restore. Optional parameter.

Examples

Restore all images that have backups.
wp smush restore

Restore single image with ID = 10.
wp smush restore --id=10

Restore all images on a site with slug blog on a WordPress multisite instance using subdomains.
wp smush restore --url=blog.example.com

If you still have questions or need assistance after reading this document, please don’t hesitate to contact our support superheroes using the available options under the Support tab in your Hub or via the Support tab in your WPMU DEV Dashboard.

Get support in the WPMU DEV Dashboard