Please help just can't see where the problem is with code working??

Hi, I am trying to have a page on a website which each time it is visited the images changes.
I have made a dataset and have an image on the page (not linked) the code used is:


I have this working on another website and everything is the same ?? This is the error I get:


Thanks in advance for any help :slight_smile:

So you are using Yisrael (Wix Admin) tutorial for it.
https://www.grampsworkbench.com/Examples/Random-Image

I would recheck it again and see if you have missed something out, especially if you have copied the code from your other site for example.

Thanks for response, yes this only thing I could find to do what I needed I have changed the data link but can’t get it to work on my site I have looked at other site everything seems the same :frowning:

Thanks anyway!

Make sure that your collection field key for the image is really “image”

  • make sure that every record in your collection has an image and there’s no record without an image.

Thanks J.D looking into this now :slight_smile:

Legend J.D ! working fine now… image had a capital I not lower case to match thanks again !!!

That can’t be it. A field key cannot start with a capital letter. You probably just updated the field name (not the field key) and this’s not relevant to your code. But as long as your code works…

Correct, the field name was capital I which I made into lowercase and still didn’t work so I delete and renter the data using lowercase i at the start it worked…thanks again J.D.

If you want to make sure it won’t throw an error even if some of your records are missing the image, then put the following line after line 12 (in your screenshot):

items = items.filter(e => e.image);

Can I offer you a job J.D…lol thanks

You’re welcome :slight_smile: