Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate to Unsplash API #1085

Closed
driesvints opened this issue May 28, 2024 · 5 comments · Fixed by #1144
Closed

Migrate to Unsplash API #1085

driesvints opened this issue May 28, 2024 · 5 comments · Fixed by #1144

Comments

@driesvints
Copy link
Member

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.

@driesvints driesvints added the bug label May 28, 2024
@driesvints
Copy link
Member Author

Also have no idea how we're gonna migrate the current image references.

@driesvints
Copy link
Member Author

Tim mentions the old ID's are still relevant: https://x.com/TimVanDijck/status/1795455355981304124

@driesvints driesvints linked a pull request May 31, 2024 that will close this issue
@driesvints driesvints added enhancement and removed bug labels Jul 3, 2024
@tauseefsshah
Copy link
Contributor

tauseefsshah commented Sep 26, 2024

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

@driesvints
Copy link
Member Author

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.

@tauseefsshah
Copy link
Contributor

Yes I meant how it was saved. Thank you for the clarification.
I'll work on a PR for this 😄

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

2 participants