WPIntell

Source evidence

disable specific class

Disable Lazy Load · support · 2021-02-27T19:17:00+00:00

mixedsentiment
mediumseverity
0.78relevance
9replies
Evidence linked to opportunitycommercial context

Proof Health

Open evidence

Commercial opportunities need traceable source links before they are treated as build-worthy.

4 / 26 rows with source links

15.4% of this page's analysis has direct source links.

0 build-decision rows missing links

0 rows here require auditable proof before promotion.

22 rows with no attached evidence

0 rows have source counts but still need direct links.

Conversation

support
saveatrain resolved
is there a way to disable lazy loading just for wp-post-image class? The page I need help with: [ log in to see the link] ? 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://wordpress.org/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.wordpress.org/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

Comments

9 shown
saveatrain 2021-03-08T23:51:00+00:00

?

Jeff Starr 2021-03-17T21:08:00+00:00

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.

saveatrain 2021-03-17T22:34:00+00:00

it should be possible if you add to your code a way to ignore specific image classes, like this plugin did: https://wordpress.org/plugins/native-lazyload/

Jeff Starr 2021-03-17T23:00:00+00:00

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.

Lukasz 2021-07-26T13:13:00+00:00

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.wordpress.org/reference/functions/wp_img_tag_add_loading_attr/#user-contributed-notes

Jeff Starr 2021-07-26T16:38:00+00:00

Thanks for sharing @wpfed . Will take a closer look at this and see what’s possible for the plugin. Cheers.

saveatrain 2021-07-26T21:13:00+00:00

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; }`

Lukasz 2021-07-27T14:01:00+00:00

@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 .

saveatrain 2021-07-27T17:28:00+00:00

the problem is that my hero is never a fixed name ….. 🙂 but it is a fixed div class