-
Notifications
You must be signed in to change notification settings - Fork 270
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
Width issue on vercel #1490
Comments
Thanks @danielroe, although I dont exactly understand if this is fixed by the package or I need to change my sizes attribute? Do I need to define the size for all my viewports?xs, md, lg ... etc? Is this not correct usage?
|
Hi @ejerskov! As you can see vercel provider requires you to list all the sizes you need in the config (included computed ones due to densities). So for your picture to work properly on vercel, you'll need to add this in your nuxt config: export default {
image: {
screens: {
logo: 90,
logo2x: 180
}
}
} I did fixed the other issue linked to image format as well, nothing is needed from your part if you're using export default {
nitro: {
vercel: {
config: {
images: {
formats: ["image/webp", "image/avif"],
},
},
},
}
} |
Hi @mathix420 Sorry but I still don't understand what I should do. And what do you mean I have to add the sizes to the config - so everytime I need to use the vercel image I need to define the specific sizes for that image in the nuxt.config.ts? I assume that this is only settings for one specify image, right? |
Actually presets doesn't matter in this case, but I should remove it in the example to avoid any misunderstanding! You should check my updated link, It'll be clearer: https://8a4821c1.nuxt-image.pages.dev/providers/vercel
Sadly yes... or at least try to define some rough over estimations. This is a limitation from Vercel. Best would be to list every NuxtImg widths at build time and define their sizes in the config automatically.
Yes. Example for a small portfolio website I have: image: {
screens: {
avatar: 40,
avatar2x: 80,
normalImage: 301,
normalImage2x: 602,
biggestImage: 432,
biggestImage2x: 864,
},
}, |
@mathix420, thanks I think I've got it now, however Im running into a new issue. So on smaller resolutions my banner ends up with the largest size defined in nuxtconfig which is 3000px (to support wide monitors) |
Yes, you just need to define the default breakpoints with your custom ones, https://image.nuxt.com/get-started/configuration#screens |
I already have this:
So using without width will give me 3200px on mobile width. |
Ah yes, but you should use the NuxtPicture component that will generate a responsive image. |
@mathix420, it seems to behave the same. It takes the largest width possible in a mobile viewport:
|
Im running @nuxt/image 1.8.0 and deploying to vercel.
I have this image:
Locally it generates this html correctly:
<img onerror="this.setAttribute('data-error', 1)" width="90" height="121" alt="Fanside for Liverpool FC" data-nuxt-img="" sizes="(max-width: 640px) 90px, 90px" srcset="/_ipx/f_webp&s_90x121/anfieldroad/logo.png 90w, /_ipx/f_webp&s_180x242/anfieldroad/logo.png 180w" src="/_ipx/f_webp&s_180x242/anfieldroad/logo.png" data-v-inspector="../node_modules/.pnpm/@[email protected][email protected]/node_modules/@nuxt/image/dist/runtime/components/NuxtImg.vue:2:3">
However after its been deployed to vercel, the html is:
<img onerror="this.setAttribute('data-error', 1)" width="90" height="121" alt="Fanside for Liverpool FC" data-nuxt-img="" sizes="(max-width: 640px) 90px, 90px" srcset="/_vercel/image?url=%2Fanfieldroad%2Flogo.png&w=320&q=100 90w, /_vercel/image?url=%2Fanfieldroad%2Flogo.png&w=320&q=100 180w" src="/_vercel/image?url=%2Fanfieldroad%2Flogo.png&w=320&q=100">
The width is now 320px.
The text was updated successfully, but these errors were encountered: