Don't repeat random image

Hi Everyone

I need help. I have a repeating group where I want to have a randomly generated image as part of each cell (though the rest of the cell will be filtered based on content relevant to that page).

I’ve got the random bit sorted, but I want to make sure that every image is unique. When I refresh, sometimes I get two or more cells with the same image.

I’m at a loss, can anyone help?

I’d probably recommend the following;

  1. Add a custom state to the repeating group called ‘imageList’ which has a type of image and is a list.

  2. Create a workflow that triggers on page load and sets the state of that repeating group’s imageList to Do a search for Images:items until #3's Image where your search constraints are the Type contains Arbitrary text and Image isn't empty. You also want to add the random sorting there.

  3. For each image in the repeating group cell, it should be Repeating Group's imageList:item #Current Cell's index

Should work fine but let me know.

Thanks for this @juicebox - though I don’t know how to create an expression with parentheses.

It looks like the expression will return the first three images in my database (I’m probably going to have up to 20), whereas I’d like it to randomly choose from that set, and then assign a unique image to each cell - is that the case?

Don’t worry about the parentheses, it’s just an experimental Bubble feature and it’s not required - just create the expressions ignoring the parentheses.

No worries if you have 20 - remember that it’s fetching a random 3 (based on the random sorting in the search) from the database of 20. The 3 just needs to be the number of cells that you’ll have in your repeating group.

That’s got it! Thanks for your help @juicebox !

This topic was automatically closed after 70 days. New replies are no longer allowed.