laravelio/laravel.io

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

Solution Options

  1. 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)
  2. 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

  1. How was image id set for an article before? (Didn't find anything in the code, did you remove it?)
  2. If we go with the 2nd option should I use spatie/medialibrary or 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:

return "https://source.unsplash.com/{$this->hero_image}/{$width}x{$height}";

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 😄