[Support request] A3 Lazy Load in Custom Theme Functions

Home Forums Support A3 Lazy Load in Custom Theme Functions

Viewing 9 posts - 1 through 9 (of 9 total)
  • Author
    Posts
  • #840111
    Matthew

    I’m trying to get the A3 Lazy Load plugin to lazy load images that have been added to some theme elements and hooks on my site.

    The plugin developers talk about adding this code:

    apply_filters( ‘a3_lazy_load_images’, $your_content, null );

    However, I’m not sure where I would put this?

    GeneratePress 2.2.2
    #840233
    Tom
    Lead Developer
    Lead Developer

    I assume you would add it using one of these methods: https://docs.generatepress.com/article/adding-php/

    However, I’m not sure what $your_content would be. Do they offer more information on what that variable should hold?

    #844277
    Matthew

    Here is a reply they gave someone else, on a different theme:

    Change the following:
    return ( ‘’ !== $first_image ) ? $first_image : false;

    To:
    return ( ‘’ !== $first_image ) ? apply_filters( ‘a3_lazy_load_images’, $first_image, false ) : false;

    So I’m assuming you put it in where the theme is calling up images for GeneratePress elements? Where do I find that?

    #844726
    Tom
    Lead Developer
    Lead Developer

    Hmm, I’m afraid I don’t know how that code would apply to GeneratePress. Have you tried asking their support for instructions? Are you trying to apply this to featured images?

    #845178
    Matthew

    I’m trying to apply this to images I placed in the “Elements” section, as a “Hook”. Their support recommends reaching out to the theme developer, so I’m kind of caught in the middle.

    Both of you recommend talking to the other one… :p

    Can I include PHP in the hook itself somehow?

    This is what I have in there:

    <div class="instagram-footer">
    <img src="https://expertvagabond.com/wp-content/uploads/instagram-footer-expertvagabond.jpg" alt="Follow Matt on Instagram">
    </div>
    <div class="media-footer">
        <h4>AS SEEN ON:</h4>
    <img src="https://expertvagabond.com/wp-content/uploads/media-logos-footer.jpg" alt="Expert Vagabond Media Features">
    </div>
    #845190
    Matthew

    Or, as an alternative, could I turn this element hook into a custom widget somehow? Images displayed in the theme’s widgets seem to be lazy-loading with no problems.

    #845744
    Tom
    Lead Developer
    Lead Developer

    You can use PHP in a hook, you just need to check the “Execute PHP” checkbox. The hook is simply outputting HTML in this case, it should be easy to add any necessary classes/data attributes that A3 requires. Not sure why they wouldn’t know what to add to the element.

    You can always use a plugin like this to add a widget to the Element: https://wordpress.org/plugins/widget-shortcode/

    #845870
    Matthew

    Ok, thanks!

    #846076
    Tom
    Lead Developer
    Lead Developer
Viewing 9 posts - 1 through 9 (of 9 total)
  • You must be logged in to reply to this topic.