You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to figure out how to have the returning image not "objectFit: cover" (zoom in and crop out parts of the image) when given manual height()/width(), but instead "objectFit: contain" (zoom out and create empty space).
From my understanding this is where .fit() comes in. But I can't seem to get that function to do anything at all - none of the strings from the docs seem to have any effect on the returning image.
Been trying the Slack help channel but to no avail. Is it just me misunderstanding the docs or is this a bug?
To Reproduce
// myImage is 1000 x 500
const src = imageUrlBuilder(client)
.image(myImage)
.fit("clip")
.width(500)
.height(500)
.url();
<img src={src} />
Expected behavior
I expect a 500x500 image, with the image contained, and transparent/colored areas top/bottom.
Describe the bug
I'm trying to figure out how to have the returning image not "objectFit: cover" (zoom in and crop out parts of the image) when given manual height()/width(), but instead "objectFit: contain" (zoom out and create empty space).
From my understanding this is where
.fit()
comes in. But I can't seem to get that function to do anything at all - none of the strings from the docs seem to have any effect on the returning image.Been trying the Slack help channel but to no avail. Is it just me misunderstanding the docs or is this a bug?
To Reproduce
Expected behavior
I expect a 500x500 image, with the image contained, and transparent/colored areas top/bottom.
Which versions of Sanity are you using?
"sanity": "3.63.0",
"@sanity/image-url": "^1.1.0",
The text was updated successfully, but these errors were encountered: