Hi everyone,
So I'm building a photography website and I want the homepage to feature a single picture picked at random. I've tried achiving this using several mathods but nothing worked out and I'm lost. :P
I'd love to hear your ideas. Thanks!
Important forum update
This forum is migrating to one unified Wix community forum starting July 26th, and will be read-only during the process.
Wishlist Page is the official platform for requesting new features. You can vote, comment, and track the status of the requested features.
Hey Jannu,
The Random Image example should give you a good start.
hey guys,
Can you help me with the error code I'm receiving? I copy & pasted to code above, but it does not work properly: Loading the code for the 2 Rate page. To debug this code, open la9wx.js in Developer Tools.
Wix code SDK Warning: The src parameter of "image1" that is passed to the src method cannot be set to null or undefined. Do you know what I need to do?
UPDATE - image loads but it is the same image every time, it is not random. It is the image i set #image20 to initially. It loaded once I replaced the dataset name in my above code with #dataset1 (the corvid title for the data set on the home page).
I was able to get the link to work and I tried to mirror what you did. I created a data set, I created a collection, I connected the data set to the collection. Now I believe I need to connect to a page element to get everything to work. What type of element do I need to connect to? Any suggestions? BTW - What I am trying to do is rotate out banner ad images all going to the same link.
Hi,
Can you try again ? the link should work
Hi. Did you guys ever figure this out? Im trying to do the same thing, but the "Random Image" link doesn't work..
Hi Roi Dolev, Did you ever figure it out? I'm trying to do the same.
Cheers
Jannu
Hi Roi,
I found this thread on stackoverflow.
Once you got your image's source just assign it to the image element.
For example:
$w('yourImage').src = imageSource;
Feel free to paste your code here
Roi
I'm super lost.. can someone please help me with this?
Thanks Ido and Geo!
I managed to figure out creating a collection and connecting it to the image element, but I'm confused when it comes to using Math.random() with the collection using the page code panel. I'm just so very lost. Help?
Thanks again!
Hi Roi,
Add the images to a collection and use Math.random() to get a random image and set it to your gallery or standalone image element