Unsplash has retired the use of the source path for hotlinking images. I've worked with @AdrianGonz97 and we've managed to pull the list of images via their new API, which is the officially supported path for this.
For example, here's the old format:
https://source.unsplash.com/YOErFW8AfkI/200x200
The new format will be:
https://images.unsplash.com/photo-1617296538902-887900d9b592?ixid=M3w0Njc5ODF8MHwxfGFsbHx8fHx8fHx8fDE2ODc5NzExMDB8&ixlib=rb-4.0.3
And resizing is handled via query params appended at the end of the image path:
https://images.unsplash.com/photo-1617296538902-887900d9b592?ixid=M3w0Njc5ODF8MHwxfGFsbHx8fHx8fHx8fDE2ODc5NzExMDB8&ixlib=rb-4.0.3&q=80&fit=max&auto=format&h=200&w=200
In the short term, let's implement a new utility service in the Skeleton documentation site that will store these values in a static file that references the Unique ID (see unsplashImages below), as well as implement a utility function that will retrieve the images on demand at at the desired size. The idea being that we document the original ID and the generated API path id, while still making it clear what images are available to use.
We'll be able to reference the original source URL like so:
https://unsplash.com/photos/{unsplashID}
In the future we'll look to migrate to a proper CDN where we self host these images and can resize the images on the fly via query params, similar to the old Unsplash method. Services such as Cloudflare offer what look to be reasonably priced options for this:
Unsplash has retired the use of the
source
path for hotlinking images. I've worked with @AdrianGonz97 and we've managed to pull the list of images via their new API, which is the officially supported path for this.For example, here's the old format:
https://source.unsplash.com/YOErFW8AfkI/200x200
The new format will be:
https://images.unsplash.com/photo-1617296538902-887900d9b592?ixid=M3w0Njc5ODF8MHwxfGFsbHx8fHx8fHx8fDE2ODc5NzExMDB8&ixlib=rb-4.0.3
And resizing is handled via query params appended at the end of the image path:
https://images.unsplash.com/photo-1617296538902-887900d9b592?ixid=M3w0Njc5ODF8MHwxfGFsbHx8fHx8fHx8fDE2ODc5NzExMDB8&ixlib=rb-4.0.3&q=80&fit=max&auto=format&h=200&w=200
Short Term Fix
In the short term, let's implement a new utility service in the Skeleton documentation site that will store these values in a static file that references the Unique ID (see
unsplashImages
below), as well as implement a utility function that will retrieve the images on demand at at the desired size. The idea being that we document the original ID and the generated API path id, while still making it clear what images are available to use.We'll be able to reference the original source URL like so:
https://unsplash.com/photos/{unsplashID}
Something like this:
Long Term Fix
In the future we'll look to migrate to a proper CDN where we self host these images and can resize the images on the fly via query params, similar to the old Unsplash method. Services such as Cloudflare offer what look to be reasonably priced options for this:
https://www.cloudflare.com/lp/pg-images/