-
Notifications
You must be signed in to change notification settings - Fork 4
Add a way to consistently get the same image #5
Description
It would be nice if there was a way to make a request using a stable URL and always get the same image back for that request.
One simple option
I have seen some placeholder services that will always return the same image for a given size. For example, service/300x300, no matter how many times you request it or where from, it will always return the same image instead of a random image.
This option isn't great though, because frequently mockup pages will have multiple img tags of the same size, and would want different photos to populate them.
User-provided value option
The first thing I thought of would be to add another value, e.g. service/300x300/1, service/300x300/2, service/300x300/3315fa35180cz3. This number wouldn't really be an identifier. Instead, the service could take the extra value and make a hash of it, and somehow have a stable mapping of hash to image.
service/300x300 would still return a random image. But if a user wants to use a stable identifier and get a consistent image, they can provide any value after the size. (I don't know how difficult this would be with the API, though.)
The advantages is that a mockup could still have different images for different tags
<figure>
<img src="http://spaceholder.cc/300x300/first-thing">
<figcaption>First Thing</figcaption>
</figure>
<figure>
<img src="http://spaceholder.cc/300x300/second-thing">
<figcaption>Second Thing</figcaption>
</figure>
<figure>
<img src="http://spaceholder.cc/300x300/third-thing">
<figcaption>Third Thing</figcaption>
</figure>
Other options
I haven't thought this far, but there might be better ideas out there.