This thread is resolved. Here is a description of the problem and solution.
Problem:
The customer duplicated a site, and on the new version (SilverCoast), property images were missing. The image src attributes pointed to placeholders (data:image/gif;base64...) instead of actual image URLs. The backend displayed images correctly, but they did not show up on the frontend.
Solution:
We identified that the issue was related to custom code responsible for fetching media IDs using full media URLs. The original code checked the database for the full URL, including the domain, which failed after site duplication. We modified the code to extract the filename and match it in the database, ignoring the domain format. This allowed the media ID retrieval to work correctly across sites.
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.
I have duplicated the site hidden link to hidden link
On the SilverCoast website, the images for the property are missing, please compare hidden link with hidden link
Instead of jpg images, the src has been changed to <img decoding="async" src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" data-orig-src="" width="" height="" alt="" title="" aria-label="" class="img-responsive wp-image- lazyloaded">
If you try to edit that post(Villa te Huur in Santa Catarina) in the back end, do you see the media in there in the migrated site? If you compare it to the original site, do you spot any differences in the post edit screen?
What if you try to edit the view and update the gallery in the migrated site, checking if the custom field is properly set up in there and making the needed adjustments?
- The backend looks just fine, all property images are visible.
- I have switched position of the last 2 images to trigger some kind of update, but the problem still persists.
- I have edited the View to limit to 10 images, but the problem still persists.
I checked it that if I delete one of the images of the gallery in the post edit screen and upload the same image again it starts showing up:
hidden link
So the issue is probably not coming from the template but something with the images.
I'd like to ask permission to make a copy/staging version of your site where I can debug this closely without affecting the live site. I'll make sure to delete this copy as soon as we get this issue fixed.
I need to switch themes, disable plugins etc. I'm afraid of debugging directly on the live site and cause issues to your visitors. Also, it is important to test a different setup as part of the troubleshooting.
If you already have a staging or could create one, it is even better, I enabled the private fields for your next reply in case you have it, if not I can create it.
Upon further review, I noticed that the issue steamed from this custom code responsible for calling the avada gallery shortcode passing the IDs inside the theme's function file:
add_shortcode('repeating-images-gallery', 'repeating_images_gallery_func');
function repeating_images_gallery_func($atts, $content) {
global $post, $wpdb;
$images = get_post_meta($post->ID, 'wpcf-image-gallery', false);
$ids = array();
foreach ($images as $image) {
$attachment_id = $wpdb->get_var($wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE guid = %s",
$image
));
$ids[] = $attachment_id;
}
$out = do_shortcode('[fusion_gallery image_ids="' . implode(",", $ids) . '" layout="grid" columns="4" column_spacing="20" lightbox="yes"][/fusion_gallery]');
return $out;
}
I changed the code slightly, excluding the domain format of the media URL checking, https/http, www/non-www. So now instead of checking for something like this in the DB:
hidden link
It'll go looking for this and retrieve the media ID correctly:
/wp-content/uploads/2024/04/image00033.jpeg
Please check the final code:
add_shortcode('repeating-images-gallery', 'repeating_images_gallery_func');
function repeating_images_gallery_func($atts, $content) {
global $post, $wpdb;
$images = get_post_meta($post->ID, 'wpcf-image-gallery', false);
$ids = array();
foreach ($images as $image) {
// Extract the filename from the full URL
$file_name = basename($image);
// Search for the attachment by filename, ignoring the domain
$attachment_id = $wpdb->get_var($wpdb->prepare(
"SELECT ID FROM $wpdb->posts WHERE guid LIKE %s",
'%' . $file_name
));
// Only add non-null IDs to the array
if ($attachment_id) {
$ids[] = $attachment_id;
} else {
}
}
// Generate the gallery shortcode output
$out = do_shortcode('[fusion_gallery image_ids="' . implode(",", $ids) . '" layout="grid" columns="4" column_spacing="20" lightbox="yes"][/fusion_gallery]');
return $out;
}
I tested it and it seems to be working now, can you please review it?
Thank you,
Mateus
Applying the updated code to the original website (2ndplaceinportugal.com) is recommended for consistency and to prevent potential future issues. However, if the original site hasn't experienced similar problems and you prefer not to modify it, leaving it unchanged is also fine. The choice is yours, but updating both sites ensures they function consistently.
If you decide to update, I'd recommend making a backup fist, just in case.