View Categories

WebP and AVIF – Exclude some site parts from the picture tag replacement

If you are delivering WebP or AVIF files using ShortPixel using the <PICTURE> tag syntax method, you will notice that there is no setting to exclude images from having their tags replaced, which would be useful if you’d like to serve a specific file in its original format.

However, there are some workarounds for that:

  1. If the images that appear in a section of the site (WooCommerce galleries for example) have a particular name convention (let’s say they all start with myWoo_ ), you could use the Exclude patterns setting located on Settings > ShortPixel > Exclusions (you need to have the Advanced Mode enabled to be able to access this menu). Following the previous example, you would have to input myWoo_ into that settings field. The downside is that these excluded images won’t be optimized at all.
  2. Turn off temporarily the WebP/AVIF setting (Settings > ShortPixel > WebP/AVIF & CDN > Create WebP/AVIF Images) and optimize only the specific images you don’t want in WebP/AVIF format. This will deactivate the generation of WebP/AVIF and will make the plugin not serve the WebP/AVIF images. Bear in mind that if you already optimized those images with the WebP/AVIF setting on, you should first restore them and then reoptimize them with the WebP/AVIF setting off.
  3. A third option, particularly useful if you don’t want to spend credits re-optimizing your images with the WebP setting disabled, is to delete the .webp counterparts of the images from your server using an FTP client or a file manager. This way, ShortPixel will detect that the .webp files are missing and will serve the JPG/PNG versions instead. Keep in mind that this approach will leave the database in an outdated state because the plugin will still assume it created the WebP files (you will see it on the Media Library).