Open predbjorn opened 4 years ago
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();
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();