Skip Navigation

[Resolved] Background image not appearing after ajax filter

This thread is resolved. Here is a description of the problem and solution.

Problem:
The customer reported that when the view's results are updated through AJAX, background images shown in the view's loop get missing.

Solution:
The view was using the 'acf' shortcode to get the background image URL from the ACF plugin's image type field.

But, when the AJAX operation was performed on the view, the value of that field was not becoming available, so suggested to replace it with the Toolset's 'wpv-post-field' shortcode.

Relevant Documentation:
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-field

This support ticket is created 2 years, 4 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 5 replies, has 2 voices.

Last updated by davidR-12 2 years, 3 months ago.

Assisted by: Waqar.

Author
Posts
#2418897

On the page here:

hidden link

The images are being displayed initially. However, once the filter is used, the background images disappear. I am using a Bootstrap layout created by Toolset and the "AJAX results update when visitors change any filter values". When I am logged into the site the issue does not happen and the images appear. But when not logged in they do not appear on any browser. The background image which should be in the 'work-single-main-inner' div is listed as "background-image: url((unknown));"

Regards,

David

#2419569

Hi David,

Thank you for contacting us and I'd be happy to assist.

If you're only experiencing this as a guest (i.e. non-logged-in) visitor, it is most likely related to a cache issue. Most cache solutions, show the cached version of the pages to the guests, but, the updated/live version to the logged-in admins.

When I visit your website's homepage directly, I can see the issue of the missing background images. But, if I visit with the same page with some URL string, for example "{yourwebsite.com}/?no-cache=true", it shows the password protection message and not the page itself.

I'll recommend clearing all involved caches and then checking the page and the search filter again.

regards,
Waqar

#2419609

Hi Waqar,

Thank you for your quick response.

The issue isn't caching as far as I can tell. I have tried clearing the cache without success and have turned it off without success. I have a local dev version of the site that has no caching on it in the first place and the issue persists. I have tried turning off all plugins except Tools, Views and ACF (which is where the image is coming from via a custom field) and still the issue is there.

Regards,

David

#2419879

Thanks for writing back.

To troubleshoot this further, I'll need to see how this view is set up in the admin area.

Can you please share the temporary admin login details in reply to this message? I'll also need your permission to download a clone/snapshot of the website, in case it needs to be investigated on a different server.

Note: Your next reply will be private and making a complete backup copy is recommended before sharing the access details.

#2420491

Thank you for sharing the access details.

During troubleshooting, I noticed that the view is using a custom shortcode "get_image_URL_by_ID", to get the URL from the image, stored in the ACF plugin's image type field.

In the code of this shortcode, the "acf" shortcode was being used to get the ID of the image from that image field:


$image_ID = do_shortcode('[acf field="'.$atts['field'].'"]');

But, it turns out that when the AJAX operation is performed on the view, the value of that field is not available. Changing it to use the Toolset's "wpv-post-field" shortcode instead, fixed it:
( ref: https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#wpv-post-field )


$image_ID = do_shortcode('[wpv-post-field name="'.$atts['field'].'"]');

( screenshot: hidden link )

#2420783

Hi Waqar,

Thank you for that. Thats fixed the issue, and it all works perfectly on desktop, tablets and mobile.

Warm regards,

David