- This topic has 9 replies, 2 voices, and was last updated 3 years, 3 months ago by
David.
-
AuthorPosts
-
March 2, 2023 at 6:11 am #2552645
Bernhard
Hi there,
it seems that GP Premium adds to all imagesloading="lazy"My featured images in the header block have the class crazy-load added to trigger disabling of lazy load.
`
When I used WP Rocket or Litespeed, these plugins filterloading="lazy"out. But I had to disable both due to compatibility issues with Ezoic and the Ezoic optimization “Leap” loops thru the lazy load and does not filter it out.My test setup:
With litespeed plugin appears no “lazy”
Disabling litespeed “lazy” appears
Then I disabled all plugins until “lazy” disappeared and this is only when GP Premium is disabled. Other plugins still active in my setup are GP Blocks, GP Blocks pro and Polylang.Screenshots:
GP Premium active
GP Premium disabledI need to solve the problem urgently.
March 2, 2023 at 9:45 am #2553045David
StaffCustomer SupportHi there,
try adding the following PHP Snippets to your site:
add_filter( 'wp_omit_loading_attr_threshold', function($omit_threshold){ if ( is_single() ) { $omit_threshold = 0; } return $omit_threshold; } ); add_filter( 'wp_get_attachment_image_attributes', 'fp_no_lazy_featured_image', 10, 3 ); function fp_no_lazy_featured_image( $attr ) { if ( false !== strpos( $attr['class'], 'attachment-full' ) ) { unset( $attr['loading'] ); } return $attr; }March 2, 2023 at 10:51 am #2553140Bernhard
Hi David,
lazy is still there.March 2, 2023 at 10:58 am #2553152David
StaffCustomer SupportSorry i think i sent you the wrong PHP
Try:
function disable_lazy_load_featured_images($attr, $attachment = null) { unset( $attr['loading'] ); return $attr; } add_filter('wp_get_attachment_image_attributes', 'disable_lazy_load_featured_images');March 2, 2023 at 12:34 pm #2553259Bernhard
Hi David,
now it saysimage loading="lazy"
ScreenshotI would prefer to disable the lazy loading completely in GP Premium and to address it in an optimization system using the CSS classes.
March 2, 2023 at 1:06 pm #2553276David
StaffCustomer Supportdamn… I am having a day of it lol
The
loading=lazyattribute comes from WP.
Theme simply uses certain core functions like getting the image, that adds them.Add this snippet:
add_filter( 'wp_lazy_loading_enabled', '__return_false' );This will tell WP to stop it
March 2, 2023 at 1:28 pm #2553299Bernhard
OK, now it’s gone 🙂 . Do I need both snippets or only the last one?
March 2, 2023 at 1:43 pm #2553314David
StaffCustomer Supportjust the last one… and I need a large whiskey lol
Glad to hear its workingMarch 2, 2023 at 2:35 pm #2553356Bernhard
Not only you 🙂
I have been looking into this for over half a year, but I had never done this test. Simply because I couldn’t imagine GP Premium interfering with lazy-load on images.
In any case, I’m glad it’s solved now.Thank you David and cheers, have a nice day
March 3, 2023 at 1:46 am #2553706David
StaffCustomer SupportJust to be clear, its WordPress that adds the
loading=lazyattribute.
The only thing GP Premium does ( alllows ) is the (re)moving of the featured image, which can result in certain WP functions behaving differently. Theres more info on that here if you want boring read lolGlad to hear its working.
-
AuthorPosts
- You must be logged in to reply to this topic.