Site logo

Archived topic

A3 Lazy Load in Custom Theme Functions

8 replies · Started by Matthew on March 15, 2019

Viewing posts 1–9 of 9

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?

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?

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?

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>

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.

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/

Ok, thanks!

No problem :)

This archived topic is closed to new replies.