View Categories

Deleting WebP or AVIF files created by ShortPixel

If you have created WebP and/or AVIF files with ShortPixel Image Optimizer (SPIO) and for some reason you want to delete them from your file system, do the following:

  1. Log into your hosting provider's control panel and access the file manager. Alternatively, you can also use an FTP client or login via SSH to your server. Please contact your hosting provider if you need help with this step.
  2. Navigate to the path where your WebP/AVIF files are located. This is usually /wp-content/uploads/YYYY/MM, where "YYYY" is the year and "MM" is the month in which the upload occurred.

  3. Delete any WebP/AVIF files you wanted to delete. If you are logged in via SSH, you just need to run this command: find . -name "*.webp" -type f -delete

The reason ShortPixel Image Optimizer does not delete these files with one click is that there can be many issues with file permissions, paths and such. In short, this would mean that the plugin becomes a file manager plugin, which we do not want.

  1. Go to /wp-content/themes/your_theme (where "your_theme" is the folder of the theme you are using) and edit the functions.php file.
  2. Add the following line: add_filter('shortpixel/image/filecheck', function () { return true; });

  3. Save the file.
  4. Go to your WordPress dashboard, and then to Settings > ShortPixel > Tools.
  5. Click on the "Search and Migrate All" button. The purpose of this step is to remove the information that SPIO stores about the WebP/AVIF files from the database so that new information can be created and the database remains in a consistent state.
  6. Follow the instructions until the process is complete.
  7. Go back to edit the functions.php file and remove the line you added in step #4. Save the file.

That's it!