Exclusions from Optimizing or Lazy Loading

You might want to exclude images from being optimized or lazy-loaded, and you can acquire this in two ways:

🚫 Using Exclusions
🧹 Using Filter

🚫 Using Exclusions

You can do this in Optimole by going into Optimole > Settings > Advanced > Exclusions. Here you can exclude by:

  • File Name - eg. file contains “_slide”
  • Extension - eg. “SVG” 
  • Page URL - eg. “home”

For lazyload, you can also exclude by Class Name (eg. “class_to_not_load”) .

This feature can help you fix some compatibility problems with some themes or plugins.

🧹 Using Filter

You can copy and paste this code snippet into the plugin's file and replace the sample URL with the one you need:

add_filter('optml_dont_replace_url', function( $old, $url ) {
     if ( $url === 'https://example.com/wp-content/uploads/2018/09/1.jpg' ) {         
         return true;    
     return $old;  
}, 10, 2);

We constantly work on improving the plugin, but sometimes you might need to use this until a patch or fix is ready.

Did this answer your question? Thanks for the feedback There was a problem submitting your feedback. Please try again later.