That's no real magic. You have to tell the website what picture to display for a given html-request. So if "someone" says it will be a jack of hearts, you tell the program running on the server to display a jack of hearts if that particular someone requests that page.

That's comparable with a personalised ad. If you and I visit the same page, it is programmed to look at your and my viewing history, So I see an ad for a red chair, and you see an ad for whatever you searched for recently.

The only issue is how to identify that "someone". You can hardly ask the participant to tell you his IP-address. So it must be based on timing and/or on something he enters himself, like his name.