- This topic has 12 replies, 3 voices, and was last updated 1 year, 10 months ago by David.
-
AuthorPosts
-
September 27, 2022 at 11:08 pm #2355965Narender
Hey folks!
I am using the latest version of GeneratePress, GP Premium, GenerateBlocks Pro, etc. Recently, I noticed that the images inside the article content aren’t getting the native lazy loading tag automatically. Then, I tried deactivating all the plugins and checking the lazy load implementation. The problem occurs only when I am activating the GeneratePress Premium Plugin.As soon as I activate the plugin, the Native Lazy Loading tag
loading="lazy"
goes away from the content image. Here is a sample article you guys may debug.September 28, 2022 at 10:06 am #2356661YingStaffCustomer SupportHi there,
As you are already using GB, can you try using the image block from GB instead of the WP image block?
Let me know if that works.
September 28, 2022 at 9:29 pm #2357154NarenderHey Ying,
I don’t use Block Editor. I prefer the Classic Editor so using the same.September 29, 2022 at 9:37 am #2357933YingStaffCustomer SupportHum..but you have GB and GB pro installed and activated, GB pro is a paid plugin.
Anyway, the issue is from the Blog module of GP premium, it should be fixed for GPP 2.2.0-alpha.1.
In the meantime, you can use the lazyload function of WP Rocket.
September 29, 2022 at 8:06 pm #2358330NarenderFor this particular website, I use GB Blocks just for some portions such as Query Loop for the Homepage & Sidebar, Entry Meta, etc. Will wait for the theme update…
October 28, 2022 at 6:29 am #2391425NarenderHey,
I am using the recently updated versions of GP Premium and GeneratePress Theme but still, the issue is the same. Native Lazy Loading isn’t working for the posts created with the Classic Editor. Hasn’t it been fixed?October 28, 2022 at 6:59 am #2391474DavidStaffCustomer SupportHi there,
do you have a sample post that has more than one image in the content where i can see the problem?
October 28, 2022 at 7:11 am #2391494NarenderHey David,
I have added two images to this single post. However, it wasn’t the case earlier. The Native Lazy Loading Tag used to appear even if I had a single image in the content.October 28, 2022 at 8:50 am #2391867YingStaffCustomer SupportHi there,
I can’t replicate the same issue on my end using classic editor with the latest GP and GP premium.
Can you try disable all other plugins?
October 28, 2022 at 9:15 am #2391904NarenderI have just deployed a staging site for your guys to debug it. I have disabled every plugin except Classic Editor, GPP, and Generate Blocks and the issue still persists for me.
October 29, 2022 at 4:09 am #2392534DavidStaffCustomer SupportOk, so what is happening here:
WordPress lazy load has a few different rules as to when it adds the lazy-loading class.
One of those is thewp_omit_loading_attr_threshold
filter:https://developer.wordpress.org/reference/functions/wp_omit_loading_attr_threshold/
By default this threshold value is set to
1
. Which means the first image in your post content, whether that be the featured image or a media attachment gets excluded from lazy loading.To show this, I edited one of your posts to include 4 images:
https://test.odishassc.in/gujarat-postal-circle-recruitment/
Image 1 has NO
lazy
attribute.
Images 2 and 3 HAS thelazy
attribute.
Image 4 has NOlazy
attribute as it the same image attachment as Image 1.So this is working as expected.
The difference with GP Premium de-activated:
In your GP Premium -> Customizer > Layout > Blog –> Featured images you have the Post featured images disabled.
When you disable GP Premium the featured image now gets output in your post content, and it gets counted as the first image.So on posts that only have a single image, you will see no lazy load.
If you want to make sure all images have the lazy load, add this PHP Snippet:add_filter( 'wp_omit_loading_attr_threshold', function($omit_threshold){ if ( is_single() ) { $omit_threshold = 0; } return $omit_threshold; } );
Does that make sense ?
October 29, 2022 at 11:46 pm #2393548NarenderThank you very much, David. It totally makes sense now.
October 30, 2022 at 6:12 am #2393799DavidStaffCustomer SupportAwesome – it took me a while to understand it lol
Glad to be of help -
AuthorPosts
- You must be logged in to reply to this topic.