david.dev

source.unsplash.com/random is not working

daviddev


In my previous version of this blog I had an idea to add a photo to each article. The easiest way, explained in many tutorials, was to use unsplash for example by calling:

https://source.unsplash.com/random/[WIDTH]x[HEIGHT]

This worked file until it didn't and it crashed the whole blog. Apparently unsplash has discontinued this URL that now returns an Heroku error.

I understand that unsplash might now allow you to fetch random photos through an API but my suggestion is not to rely on external sources. Host your photos (from unsplash or otherwise) locally in your site: it would be faster and more stable for sure.

I have now switched to photos from the Swiss National Museum which are royalty free and hosted by myself.

👏 49

made with â™Ĩī¸ Š david.dev 2023