rosell-dk / webp-express

Wordpress plugin for serving autogenerated WebP images instead of jpeg/png to browsers that supports WebP
GNU General Public License v3.0
222 stars 63 forks source link

Add WP CLI command for convert #498

Closed rosell-dk closed 3 years ago

rosell-dk commented 3 years ago

Already completed by @ratnayake: https://github.com/rosell-dk/webp-express/pull/492

@vasikgreif created something very similar here, but with progress bar: https://wordpress.org/support/topic/wp-cli-suport-for-bulk-convert/#post-14561675

I think I'll go with the PR, though

rosell-dk commented 3 years ago

Adding annotations... https://make.wordpress.org/cli/handbook/references/documentation-standards/ https://firxworx.com/blog/wordpress/how-to-write-custom-wp-cli-commands-for-wordpress-automation/ https://docs.wpvip.com/how-tos/write-custom-wp-cli-commands/

CLI: https://make.wordpress.org/cli/handbook/references/internal-api/wp-cli-utils-make-progress-bar/

rosell-dk commented 3 years ago

You can use the --help option to learn about the options: wp webp-express --help. Displays the available commands wp webp-express convert --help. Displays the available options for the "convert" command.

A few examples: wp webp-express convert: Creates webp images for all unconverted images wp webp-express convert --reconvert: Also convert images that are already converted wp webp-express convert themes: Only images in the themes folder wp webp-express convert --only-png: Only the PNG images wp webp-express convert --quality=50: Use quality 50 (instead of what was entered in settings screen) wp webp-express convert --quality=50: Use quality 50 (instead of what was entered in settings screen)

wp webp-express flushwebp: Remove all webp images wp webp-express flushwebp --only-png: Remove all webp images that are conversions of PNG images

I'm considering adding commands for viewing status, viewing conversion stats, generating the .htaccess files and modifying the settings. Please let me know if you need any of these or perhaps something else.

vaclavgreif commented 3 years ago

Very cool, thanks!

rosell-dk commented 3 years ago

Just published (0.20.0)