Last active
March 22, 2023 15:33
-
-
Save neverything/b17bbc75e558e6525756476ae2d0324d to your computer and use it in GitHub Desktop.
Sometimes you only want the original images and not the generated sizes <name-of-image>-150x150.png. This command deletes all the files with a certain pattern in the file name. See https://silvanhagen.com/wordpress-delete-generated-images/ for more details.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# List the files | |
find -E . -type f -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" | |
# DANGER! Delete the files | |
find -E . -type f -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" -delete | |
# If your OS doesn't support -E (tip from https://github.com/quasel) | |
find . -type f -regextype posix-extended -regex ".*-[[:digit:]]{2,4}x[[:digit:]]{2,4}(@2x)?.(jpg|jpeg|png|eps|gif)" | |
# Improved with the help of https://github.com/markhowellsmead |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Regenerate all media files and sizes | |
wp media regenerate --yes | |
# empty space for copying |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment