Description #
CompressX Pro supports WP-CLI to facilitate your image optimization process.
With WP-CLI integration, you can easily convert images in your WordPress media library or a specific image to WebP/AVIF format, and delete converted images with a single command.
How to Convert Images using WP-CLI #
Connect to your server via SSH #
Log in to your website server from your preferred terminal.
Access the website root directory #
Use the command below to access the website root directory:
cd /var/www/html/yourdomain.com/wordpress
Scan for unconverted images #
Scan the WordPress media library and find all unconverted images:
wp compressx scan
Convert all images to WebP/AVIF format #
Convert all images in the WordPress media library to WebP/AVIF format:
wp compressx convert
Convert a specific image to WebP/AVIF format #
Convert a specific image to WebP/AVIF format by image ID.
wp compressx convert --type single --image=id
Note:
To find the image ID, in WordPress’s Media Library list view, hover over the image title and look at the URL that appears in the bottom-left corner of the browser window.
The URL will look something like this: ...post=123...
. The number after post=
is the image ID.
Delete all converted images #
Delete all converted WebP/AVIF images.
wp compressx delete
Delete converted images for a specific image #
Delete all converted WebP/AVIF images for a specific image.
wp compressx delete --type single --image=id