Hi guys,
I am now building a product information site with database. There are pictures for every product in row. I have already added them to my site in a thumbnail gallery by the following code:
import wixData from ‘wix-data’;
$w.onReady( function () {
// Gallery:
let refID = $w(“#dynamicDataset”).getCurrentItem().title;
wixData.query(‘Collection’).eq(‘title’,refID)
.find().then(result => {
const rowInDatabase = result.items[0];
const imagesToShow = ;
for ( let key in rowInDatabase){
if (key.includes(‘image’)) {
imagesToShow.push({src: rowInDatabase[key]})
}
}
$w(‘#gallery’).items = imagesToShow;
})
})
However, I don’t have the same amount of pictures for every product. Is there any possibility to add another condition in if ((key.includes(‘image’) || … …) to avoid the empty section? So the number of thumbnails will be automatically match to the amount of pictures in row. Since it keeps showing the empty thumbnails on page now.
I might need to sort the pictures in gallery by their key / id as well.
Any suggestion will be appreciated!
Thank you in advance!