I have a slideshow repeater that displays testimonials that include a paragraph of the testimonial text, a paragraph with the testimonial writers name, a paragraph with the testimonials writer job title and business, and a image that displays the logo for the business. However some testimonial writers might not have a logo or a business. Currently the placeholder image I used to link with the CMS displays if there is no image in the CMS. How can I make it hide the image if none exists in the CMS?
I am using the Wix Studio Editor and the CMS system to hold the collection of testimonials
I have searched google, and asked copilot AI where I found and used various velo code to target the slideshow .onchange event to check the image value and set the image to hidden or collapse. So far it either didn’t work at all or hid the image on all slides.
Hi, @ArtisanElectric !!
Hello. I believe you’ll find many similar cases and solutions by searching within this community, so I’d recommend starting there. That said, the issue you’re currently facing is likely due to not using the $w and $item selectors properly.
Please check whether the element you’re trying to hide (using methods like .hide() or .collapse()) is being selected with $w, as this can cause unexpected behavior in repeaters. Even if you are using $item correctly, the logic used to determine when to show or hide elements might be flawed, which could also lead to problems. 
This is a fundamental and important concept when working with repeaters, so I suggest reviewing the link below to help build a clearer understanding and guide you toward a solution.
This was the code I was trying to use that I found online but modified for the slideshow repeater. Copilot and the wix ai came up with so many different things that thats probably not even worth putting here. The code didn’t work. Other variations that the AI tools did suggest would sometimes make the image be hidden even if the dataset had a logo.
$w.onReady(function () {
// Write your Javascript code here using the Velo framework API
// Gets the current item properties and stores them in a variable called item
$w(“#slideshow1”).onChange(() => {
const item = $w(“#testimonialDataset”).getCurrentItem();
// Checks if the current item has a value in the “companyLogo” field
if (!item.companyLogo) {
$w(“#imageX10”).hidden;
} else {
$w(“#imageX10”).show;
}
});
});
I managed to figure it out after a break, some food, and tips from the discord community. the slideshow repeater has both a slideshow id and repeater id and you can target the repeater id (even though theres no where in the UI that shows you it). The working code is:
$w(“#repeater1”).onItemReady(($item, itemData) => {
const logoImg = $item(“#imageX10”);
if (itemData.companyLogo) {
logoImg.show();
} else {
logoImg.hide();
}
});