-
AuthorPosts
-
August 27, 2020 at 4:14 pm #1241248
How do I enable lazy-loading on images outside of the ALB? Most of my slower pages are pulling images from blogs, galleries, or portfolio items, but they all seem to have a default class of avia-img-lazy-load-not- and then a number for the image.
It’s frustrating that the default for images with this update is set to not lazy-load. Lazy-loading is the standard now, so I assumed that, with this update, the default would be that all images would be set to lazy-load.
September 2, 2020 at 12:54 pm #1242788Hey bucksharp,
Thank you for the inquiry.
You can use this snippet in the functions.php file to override the default option, and enable lazy loading of images by default.
add_filter( 'wp_lazy_loading_enabled', __return_true, 999, 10 ); remove_filter( 'wp_img_tag_add_loading_attr', ['av_responsive_images', 'handler_wp_img_tag_add_loading_attr'], 99, 3 );
Best regards,
IsmaelSeptember 2, 2020 at 5:14 pm #1242871This snippet worked for everything except the blog, gallery, and portfolio images, so my problem persists.
Actually, it ended up slowing my page load scores on GTmetrix.
- This reply was modified 4 years, 3 months ago by bucksharp.
September 7, 2020 at 11:53 am #1243938Hi,
Thank you for the update.
Would you mind providing links to the site or the pages containing the blog and galleries? Please post the details in the private field so that we can check the current site layout and settings.
Best regards,
IsmaelSeptember 8, 2020 at 7:29 pm #1244412This whole site is giving me trouble, but I’ll send you the homepage as an example.
September 11, 2020 at 1:30 pm #1245137Hi,
Thank you for the info.
Looks like the Advanced > Animation > Lazy Loading Of Images option is not enabled for the Blog Posts element. If you would like to enable the option by default, please include this additional filter in the functions.php file.
function ava_enable_lazyloading() { global $avia_config; $avia_config["alb_html_lazy_loading"] = "enabled"; } add_action("get_header", "ava_enable_lazyloading");
Lazy loading is not enabled globally or by default because it might cause issues with the default animation settings.
Best regards,
IsmaelSeptember 14, 2020 at 7:04 pm #1245810This didn’t work for me on any of my sites on individual images added by ALB or on blog images. What should I try next?
September 18, 2020 at 6:29 am #1246645Hi,
Thank you for the reply.
Does it work correctly when the elements’ option Lazy Loading Of Images is enabled for the element? Please post the login details in the private field so that we could check the site.
Best regards,
IsmaelSeptember 21, 2020 at 3:09 pm #1247377Yes, lazy-loading works when enabled manually, but my site is massive and it isn’t feasible to manually enable it for every image. Due to security reasons, I’m unable to provide login info for the site. So sorry!
September 23, 2020 at 5:45 am #1247732Hi,
Thank you for the update.
Please remove the snippets that we added previously and replace it with the following code.
function handler_wp_img_tag_add_loading_attr_mod( $attr_value, $image_tag = '', $context = '' ) { return 'lazy'; } add_filter( 'wp_img_tag_add_loading_attr', 'handler_wp_img_tag_add_loading_attr_mod', 9999, 3 );
This should add the loading attribute to the images and set the value to lazy.
Best regards,
IsmaelDecember 2, 2020 at 6:36 pm #1264555Thanks, Ismael!
That seems to be working fine! I’ll keep a lookout and let you know if I have any problems!
December 3, 2020 at 5:13 am #1264643Hi,
If you need additional help, please let us know here in the forums.
Best regards,
Jordan Shannon -
AuthorPosts
- The topic ‘Lazy-Load Not Working on Blog, Gallery, or Portfolio Item Images’ is closed to new replies.