image-url icon indicating copy to clipboard operation
image-url copied to clipboard

It includes faulty rect parameter

Open lejtzen opened this issue 1 year ago • 2 comments

Why does the imageUrlBuilder add the faulty rect parameter to the url?

Example

import createImageUrlBuilder from '@sanity/image-url'

const imageUrlBuilder = createImageUrlBuilder({ projectId, dataset })
const url = imageUrlBuilder.image(source).width(300).height(50).fit('clip').url()

console.log(url)

url outputs https://cdn.sanity.io/images/XXXXXXXX/XXX/filename.png?rect=0,75,1200,200&w=300&h=50&fit=clip. I expected it to be https://cdn.sanity.io/images/XXXXXXXX/XXX/filename.png?w=300&h=50&fit=clip.

This must be a bug? Is there any other way to get the image url and an image constrained within the given width and height without cropping or distorting the image?

lejtzen avatar May 16 '23 10:05 lejtzen

Also having this issue on 1.0.2.

sodevious avatar May 30 '23 01:05 sodevious

Duplicate of #32

Michael-1 avatar Jun 06 '23 12:06 Michael-1