Closed chayawit closed 4 years ago
Hi,
The easiest way is probably to load your image with Javascript from the regular /{width}/{height}
endpoint (which returns a random image), get the ID from the Picsum-ID
header, and then get the info about it from the /id/{id}/info
endpoint.
Here's a JSBin showing how this can be done: https://jsbin.com/lewivujafu/1/edit?html,js,output
I just found and fixed a bug with how we expose that header, so might take a few days for the caches to clear for some images, but should work after that.
Let me know if you have any further questions.
Thank you very much for your help.
I would like to get a random picture to show on the web page. The page visitor can then download the picture if they like it. Right now I can achieve this with the static random image function using Date.now() as the seed. However it would be better to show the full info as we can get from the
info
endpoint, e.g., author, url. For example, the request url could behttps://picsum.photos/200/list?limit=1
.I noticed that issue #17 also mentioned about randomised list but the discussion didn't continue further.
I will also try following this suggestion by picking a random id from https://picsum.photos/list and then use the id against
/info
.