Hi @alimohebbi
I hope you’re well today!
Currently it’s only possible to exclude some media types entirely (e.g.jpg, .png), output locations (e.g. don’t use lazy load in widgets) or exclude entire pages/URLS (and that would mean all images on such page) or images by the ID/class – but it must be specifically related to image.
A parent class will not work, I’m afraid, and it’s not possible to add image URL directly to be excluded.
But there’s a filter built-in that should do the job and would let you exclude image by URL. You would want to add following code to the site either to your theme’s “functions.php” file or as an MU plugin
add_filter( 'smush_skip_image_from_lazy_load', function( $skip, $src ){
$skip_image = 'https://domain.com/myimage.jpg';
if ( $src == $skip_image ) {
return true;
}
return $skip;
}, 20, 2 );
Note: make sure to replace example URL in it with a real URL of the image you want to skip lazy load for.
Best regards,
Adam
Hello @alimohebbi
I hope you are doing well!
We haven’t heard back from you for a while now so we’ve marked this ticket as resolved. If you do have any followup questions or require further assistance feel free to reopen it and let us know here.
Kind regards,
Nastia
Thread Starter
stocket
(@alimohebbi)
Hello Nastia,
your solution was perfect and it worked for me.
thank you.