[Smush Pro] Smush Lazy Loading Images

Hi Guys

I currently use A3 Lazy Load for image loading with ACF though a filter. I see that Smush now provides lazy loading.

Is smush currently compatible with ACF or are there plans to make it filter fields made by ACF? If so can you point me in the right direction function wise?

thanks

  • Ash
    • WordPress Hacker

    Hello Kieran

    We don’t have any known issue between Smush lazy loading and ACF plugin. So I think you can give it a try.

    Is smush currently compatible with ACF or are there plans to make it filter fields made by ACF?

    I don’t think I understood this clearly, I am sorry. Would you please explain a bit more about this?

    Please note that, the smush lazy laod works only for those images which are served through HTML. That being said, any background image or any image loaded via CSS won’t be affected by the lazy load.

    Have a nice day!

    Cheers,

    Ash

  • Kieran
    • Site Builder, Child of Zeus

    Sorry I was very vague.

    acf_the_content() is the ACF filter that the A3 lazy load plugin uses to Lazy Load images that are added to visual editor fields created by ACF .

    You can add a filter to acf_the_content() with the below:

    <?php add_filter( ‘acf_the_content’, array( A3_Lazy_Load::_instance(), ‘filter_content_images’ ),100 );?>

    My question is does Smush use the above ACF filter? If not ?what is the best way for me though PHP to hook into the above filter using Smush to Lay Load ACF fields ?

    Hope that makes sense

    K

  • Kieran
    • Site Builder, Child of Zeus

    Thanks for the update.

    Unfortunately it doesn’t work on any fields I have tried it in. Can you confirm if it should work on flexible content and repeater ACF fields?

    Could I have some PHP code of the functions or hooks or a point in the right direction as to how this is being applied? I would like to be able to trigger the functions myself and disable them when needed so a hook would be required?

    Thanks

  • Kieran
    • Site Builder, Child of Zeus

    Hi

    I just checked the code of the plugin and there is no function hooking into any ACF filters and this is the only way the plugin could support ACF?

    So basically the plugin does not currently support ACF lazy loading of images. If it helps: The plugin needs the below applied as in A3 Lazyload plugin:

    // Compatibility with ACF plugin –

    add_filter( ‘acf_the_content’, ‘smush_lazyload_funtion_here’:wink:, 100 );

    Thanks

    Kieran

  • Nithin
    • Support Wizard

    Hi Kieran,

    Sorry if we weren’t clear in our last reply, with the latest update of Smush Pro, we have changed how lazyload works. At the moment there isn’t any out of the box integration for hooks with ACF in specific with Smush Pro.

    What Smush Pro does is it’ll try to detect any images on the page, and will try to parse lazyloading feature. It should have worked on every instance including ACF, however, the feature is present in the latest update of Smush Pro v 3.2.2. Initial test done with ACF seems to work fine though.

    Just to be sure you are noticing the issue with the latest plugin update? Just double-checking, as I still notice the website reported in this ticket dev.littlebxxxxxxxx.ie/iwdg/cms_files/ having an old plugin version.

    Could you also please share a page link where ACF fields are added, and enable support access, so that we could have a better idea regarding what’s being missed with the current release, and look further about adding the acf_the_content compatibility down the road.

    You can grant access from WPMU DEV > Support > Support Access > Grant Access, or check this manual: https://premium.wpmudev.org/docs/getting-started/getting-support/#chapter-5

    Please let us know once you enable access so that we could get this sorted. Have a nice weekend. :slight_smile:

    Kind Regards,

    Nithin

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.