How to do Smart dynamic gallery?

Hi
i currently used the code for dynamic gallery (on my dynamic item page). it is working and thanks all.
this code working partially and i have 2 problems / questions about these.


(here is the code )

$w.onReady(function imatDataset_onReady() { 
	let item = $w('#imatDataset').getCurrentItem();
	$w('#imatgallery').items = [
	 {src: item.s1},
	 {src: item.s2}, 
	 {src: item.s3},
	];
   });
  1. First question: In the console on wix on preview i get: “Loading the code for the Imat (ID) page. To debug this code, open pw18x.js in Developer Tools.” → is this a problem? what does it mean and How can I correct it?

  2. second question:

for example - >> i want to display in the gallery max. 3 images for each item but not Necessarily/Always 3. So is there a solution for this?

because In some case item has only 2 or 1 image. but when in the database are lass images for any item > gallery shows empty pictures boxes — and message in console → " Wix code SDK Warning: The src parameter of item at index 1 that is passed to the items method cannot be set to null or undefined."
> > > (see screen) ________ thanks for all in advance ________


thanks

Hey
anybody here ?

Hi,

  1. this is normal, it means that it’s loading the code of the page.
  2. try this:
for (let i = 1; i < 4; i++) {
  if (item[`s${i}`]) {
    $w('#imatgallery').items.push({src: item[`s${i}`]})
  }
}

Good luck!
Roi.