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

.fit() does not seem to have any effect #72

Open
oskarengstrom opened this issue Nov 11, 2024 · 1 comment
Open

.fit() does not seem to have any effect #72

oskarengstrom opened this issue Nov 11, 2024 · 1 comment

Comments

@oskarengstrom
Copy link

oskarengstrom commented Nov 11, 2024

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

// 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.

Which versions of Sanity are you using?

"sanity": "3.63.0",
"@sanity/image-url": "^1.1.0",

@coreyward
Copy link

You seem to be hitting this bug: #32

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