Migrate to Unsplash API
Closed this issue · 5 comments
Unsplash decided to sunset their https://source.unsplash.com domain without any warning so now all image fetching is broken. We'll have to migrate to their API but think that'll get us into API limits. I don't know if the generated urls from Unsplash are long lived. If they are we could maybe save them in the database otherwise we might have to run a scheduled job to refresh them during their TTL.
Also have no idea how we're gonna migrate the current image references.
Tim mentions the old ID's are still relevant: https://x.com/TimVanDijck/status/1795455355981304124
Hi @driesvints Wanted to check if you're working on this issue because I have a working solution
- The unsplash API provides a
getendpoint that takes the imageidand returns hotlink cdnurls(The urls remains constant)

- These images are dynamically resizable so we can just pass the width and height parameters and just like https://source.unsplash.com/ have our images
Solution Options
- We can get the hotlinked cdn urls by calling the API on all image ids and save the urls in the DB in a new colunm (Then we will never need to call the api's again)
- Or from the image urls we can download and store these images in the public folder or S3 and store the urls to these images in DB (Now we have the full control and just in case they change their hotlinked image policy, the images will be safe)
My Queries
- How was image id set for an article before? (Didn't find anything in the code, did you remove it?)
- If we go with the 2nd option should I use
spatie/medialibraryor just go with the filesystem? (Media library so that images can be resized and it's just convenient)
Also please provide feedback or if you think this should be done differently
If the urls remain constant then yeah we can indeed set them in a table column. @joedixon already worked a bit on a command to go over each article here: #1090
How was image id set for an article before? (Didn't find anything in the code, did you remove it?)
It's done here:
laravel.io/app/Models/Article.php
Line 109 in 8e873eb
Or did you mean how it was saved? There's no code for that. I manually copied the identifier and added it to the record in the database. We want to eventually develop an image picker but that's quite a bit of work.
Yes I meant how it was saved. Thank you for the clarification.
I'll work on a PR for this 😄