Originally I wrote it so that when you click it a random master ID is chosen and the image displayed. Logical enough.
But then I got to thinking about image preload. Things like preload can make a huge difference to the 'usability' of a site, and it's the sort of thing I like to spend time getting right.
Preload is already incorporated into the next/back buttons, but random was going to be harder, because by definition your next image is random.
So I thought okay then, I'll put the id of the NEXT 'random' master as a parameter in the url of the 'random' link. So in fact it's predetermined but still essentially random.
Except that still doesn't preload the FIRST random image for the first time they click on 'random'.
So then I had a brainwave. Why not massively simplify it by generating the ID for the 'random' link every time the page is loaded, regardless of whether they clicked 'random' or one of the other links? That way I can easily preload the 'random' image in case someone clicks on the link, and the code is exactly the same as the normal 'detail' code, but with a predetermined random id, so the code is waaaaay simpler.
So I threw away my working-but-overly-complicated random code and just wrote it like that.
But then the horror dawned.
Now when you bookmark the 'random' link, you will always get the same image, because it's just a standard link to a detail page with a particular ID. It's passive. There's no randomisation when you click 'random': it's already decided and coded into the link.
So the question (which is what this has all been leading up to) is, is it MORE important that the random link is genuinely random if people bookmark it, than that the first random image is preloaded?
Personally I think it is, and I'm inclined to re-complicate my code again and try to cover all eventualities, but I wondered what (if anyone's still reading) the panel thought.
The ideal would be:
By default load the grid page, with a random image preloaded in case they click 'random'. If they refresh the grid page or go to a (non-random) detail page, that random image stays the same, until they click Random, at which point it displays that and chooses the next random image for preload.
Without using sessions and possibly cookies, I can't see a way of doing this. The best case scenario is, I think, that there will be an inevitable delay the first time they click 'random' because the image will not be preloaded. All subsequent ones will, though, by dint of choosing the next one when the first is loaded.
And all because people may want to bookmark the 'random' link.