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

How to change stored image size pulled from Unsplash? #93

Open
alextenczar opened this issue May 12, 2023 · 2 comments
Open

How to change stored image size pulled from Unsplash? #93

alextenczar opened this issue May 12, 2023 · 2 comments

Comments

@alextenczar
Copy link

alextenczar commented May 12, 2023

Hey, I'm wondering if there's any way to default to using one of the smaller image sizes for the selected image that's stored on Sanity. Many of the images I select are way too large and it results in a large asset (4+ MB). It would be awesome to select one of the other image size urls provided by the Unsplash API:

 "urls": {
    "raw": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&ixid=eyJhcHBfaWQiOjEwMDg3MX0",
    "full": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&q=85&fm=jpg&crop=entropy&cs=srgb&ixid=eyJhcHBfaWQiOjEwMDg3MX0",
    "regular": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=1080&fit=max&ixid=eyJhcHBfaWQiOjEwMDg3MX0",
    "small": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=400&fit=max&ixid=eyJhcHBfaWQiOjEwMDg3MX0",
    "thumb": "https://images.unsplash.com/photo-1472289065668-ce650ac443d2?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=200&fit=max&ixid=eyJhcHBfaWQiOjEwMDg3MX0"
  },

any guidance in this would be appreciated. Thank you!

@alextenczar alextenczar changed the title How to change image size pulled from Unsplash? How to change stored image size pulled from Unsplash? May 15, 2023
@LeoMacherla
Copy link

+1 I came here looking for a way to do this too!

@LeoMacherla
Copy link

LeoMacherla commented Jun 20, 2023

I've just realised that a potential solution could be to add a URL parameter on the end of the image URL to request a smaller image from Sanity. See here: https://www.sanity.io/docs/image-urls

So you could append '?h=200' to the end of the URL and Sanity would return the image with a height of 200 pixels.

This seems like a nice solution as it allows you to keep the full resolution images stored in Sanity, however, it would still use up more storage on your Sanity account

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

No branches or pull requests

2 participants