Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #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.

    #1242788

    Hey 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,
    Ismael

    #1242871

    This 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.
    #1243938

    Hi,

    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,
    Ismael

    #1244412

    This whole site is giving me trouble, but I’ll send you the homepage as an example.

    #1245137

    Hi,

    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,
    Ismael

    #1245810

    This 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?

    #1246645

    Hi,

    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,
    Ismael

    #1247377

    Yes, 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!

    #1247732

    Hi,

    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,
    Ismael

    #1264555

    Thanks, Ismael!

    That seems to be working fine! I’ll keep a lookout and let you know if I have any problems!

    #1264643

    Hi,

    If you need additional help, please let us know here in the forums.

    Best regards,
    Jordan Shannon

Viewing 12 posts - 1 through 12 (of 12 total)
  • The topic ‘Lazy-Load Not Working on Blog, Gallery, or Portfolio Item Images’ is closed to new replies.