• Jong

    (@jongycastillo)


    I noticed today that images output through code with functions like wp_get_attachment_image() are no longer getting the lazy load treatment. I checked the changelogs and it looks like a previous update changed it. On inspecting the code, there is a commented out line of code in a3-lazy-load/classes/class-a3-lazy-load.php, line 84: add_filter( 'wp_get_attachment_image_attributes', array( $this, 'get_attachment_image_attributes' ), 200 );

    If I uncomment this line of code, all works as expected.

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Contributor Nguyen Tuan

    (@nguyencongtuan)

    Hi

    That filter we stopped support from 2018 ( check the changelog ), the cause WordPress had their lazy for that function. I think some plugins or theme from your site are using old code so it works when you turn it on

    If you want to turn it ON for you without need to edit directly on our plugin, try add this code to functions.php of your current active theme

    add_filter( 'wp_get_attachment_image_attributes', array( '\A3Rev\LazyLoad', 'get_attachment_image_attributes' ), 200 );

    • This reply was modified 1 year, 1 month ago by Nguyen Tuan.
    Thread Starter Jong

    (@jongycastillo)

    Thanks! I will try it out.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘No lazy load on media assets thru code’ is closed to new replies.