- This topic has 8 replies, 2 voices, and was last updated 2 years, 4 months ago by Tom.
March 15, 2019 at 11:15 am #840111Matthew
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.2March 15, 2019 at 4:28 pm #840233TomLead DeveloperLead 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_contentwould be. Do they offer more information on what that variable should hold?March 20, 2019 at 4:12 am #844277Matthew
Here is a reply they gave someone else, on a different theme:
Change the following:
return ( ‘’ !== $first_image ) ? $first_image : false;
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?March 20, 2019 at 9:18 am #844726TomLead DeveloperLead 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?March 21, 2019 at 12:17 am #845178Matthew
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>March 21, 2019 at 12:38 am #845190Matthew
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.March 21, 2019 at 8:32 am #845744TomLead DeveloperLead 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/March 21, 2019 at 10:15 am #845870Matthew
Ok, thanks!March 21, 2019 at 3:29 pm #846076
- You must be logged in to reply to this topic.