Hi @saveatrain, sorry for the delay on this.
At this time it is not possible to do with this plugin. It may be possible using some other method, check the WordPress docs for more ideas.
Let me know if I can provide any further infos, glad to help anytime.
it should be possible if you add to your code a way to ignore specific image classes, like this plugin did:
https://ww.wp.xz.cn/plugins/native-lazyload/
It’s an interesting idea, thanks. But really this plugin is only one line of code and meant to stay as simple as possible. It does only one thing: disable WP Lazy Load completely. If you need more functionality, maybe there is another plugin that can do what you need.
I was looking for same thing, you need to search for string wp-post-image using this filter ‘wp_img_tag_add_loading_attr’
Wrote a example here:
https://developer.ww.wp.xz.cn/reference/functions/wp_img_tag_add_loading_attr/#user-contributed-notes
Thanks for sharing @wpfed. Will take a closer look at this and see what’s possible for the plugin. Cheers.
Hi Luke,
Thanks for jumping in,
Is this snipper generic, I can basically put it and it will stop any hero image of any theme?
add_filter( ‘wp_img_tag_add_loading_attr’, ‘skip_lazy_load’, 10, 3 );
function skip_lazy_load( $value, $image, $context ) {
if ( ‘the_content’ === $context ) {
// Check if needle found https://www.php.net/manual/en/function.strpos.php
if ( false !== strpos( $image, ‘hero-image.png’ ) ) {
return false; // Set to false so lazy loading attribute is omitted.
}
}
return $value;
}`
@saveatrain, it will work only if your image is called hero-image.png, you can replace bolded part with a unique string in your HTML image tag, name of image seems simplest so far in gutenberg block editor since you can’t always add a unique class to an image. Would be nice if you can add skip-lazy class to images you don’t want lazy loaded.
if ( false !== strpos( $image, ‘hero-image.png‘ ) ) {
-
This reply was modified 4 years, 10 months ago by
Lukasz.
the problem is that my hero is never a fixed name ….. 🙂
but it is a fixed div class