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

Bug / feature request: Allow desimal in width/height in imagebuilder #50

Open
predbjorn opened this issue Jan 10, 2020 · 0 comments
Open

Comments

@predbjorn
Copy link

I had a problem showing pictures on some devices because I sent a number with decimal to width. It was so hard to debug because I couldn't reproduce the error anywhere. This was my code:

imageUrlBuilder(sanityClient)
.image(this.state.sanity.mainImage)
.width(PixelRatio.getPixelSizeForLayoutSize(width))
.height(PixelRatio.getPixelSizeForLayoutSize(300))
.fit('crop')
.url();

It would be awesome if it did a Math.round(with) or something like that in the library.. So hard to debug if you get the error

My solution:

imageUrlBuilder(sanityClient)
.image(this.state.sanity.mainImage)
.width(Math.round(PixelRatio.getPixelSizeForLayoutSize(width)))
.height(Math.round(PixelRatio.getPixelSizeForLayoutSize(300)))
.fit('crop')
.url();

@predbjorn predbjorn changed the title Bug / feature request: Send desimal in width/height in imagebuilder Bug / feature request: Allow desimal in width/height in imagebuilder Jan 10, 2020
@rexxars rexxars transferred this issue from sanity-io/sanity Dec 14, 2022
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

1 participant