Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate random image by url

I have an API with the endpoints:

  • api/image/1 Returns me the image 1
  • api/image/random Gives me a random image

Whenever I make a call for a random image, like 5 times on 1 webpage, each time it's the same image. It's a little bit like https://picsum.photos/seed/picsum/200/300...

I would like to have a random image, each time. Even if I call for a random image 10 times on 1 webpage. Is there a way that this is possible?

like image 703
user1141796 Avatar asked Nov 28 '22 13:11

user1141796


1 Answers

As stated in this github issue, you can basically use https://source.unsplash.com/random/200x200?sig=incrementingIdentifier.

<img src="https://source.unsplash.com/random/200x200?sig=1" />
<img src="https://source.unsplash.com/random/200x200?sig=2" />
<img src="https://source.unsplash.com/random/200x200?sig=3" />
like image 199
kissu Avatar answered Dec 06 '22 19:12

kissu