Hide / Collapse items that are not present in the database

Hi Sharon, Nathan, still waiting… would greatly appreciate a response re how to rephrase the code for multiple items as shown in the example tutorial. If instead of the video player these are images. And there are more than 1 image that needs to be collapsed in some instances. Thank you!
In my case here is the code that works for one image collapse but I have more images that need to be collapsed on some dynamic pages:


$w.onReady(() => {
$w(“#dynamicDataset”).onReady(() => {
// Gets the current item properties and stores them in a variable called item
const item = $w(“#dynamicDataset”).getCurrentItem();
// Checks if the current item has a value in the “slide1” field
if (!item.slide1) {
// Collapses the image space if there is no value for “slide1”
$w(“#image17”).collapse();
}
});
});


Now how do I change the code above so I can collapse spaces for : !item.slide2 corresponding to #image18, !item.slide3 corresponding to #image19 and so on and so forth…

Thanks for the great work you do!