Skip to content

Instantly share code, notes, and snippets.

@Pablohn26
Created February 27, 2022 03:00
Show Gist options
  • Save Pablohn26/d4b280c27b72d6630e11dedffd16de8e to your computer and use it in GitHub Desktop.
Save Pablohn26/d4b280c27b72d6630e11dedffd16de8e to your computer and use it in GitHub Desktop.
Optimize wordpress images on Linux

Optimize wordpress images on Linux

Install packages (debian):

sudo apt-get install -y jpegoptim optipng

Then get wordpress wp-content path, for example /var/www/website-example.com/wp-content/ and run the following commands:

find /var/www/website-example.com/wp-content/ -name "*.png" -exec optipng '{}' \;
find /var/www/website-example.com/wp-content/ -name "*.jpg" -exec jpegoptim --all-progressive --strip-all '{}' \;

Remember you can add them to crontab.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment