image icon indicating copy to clipboard operation
image copied to clipboard

NuxtImage with Sanity returning incorrect density letter (w instead of x)

Open richgcook opened this issue 4 months ago • 0 comments

I'm using NuxtImage (1.11.0) on Nuxt (3.13.2) and I'm using Sanity as the provider. Everything seems set up correctly however the densities are returning 1w, 2w instead of 1x, 2x and it's thus generating an image at 1px and 2px.

nuxt.config.js

image: {
	screens: {
		phone: 0,
		'tablet-portrait': 768,
		'tablet-landscape': 1024,
		'laptop': 1200,
		'desktop': 1440,
		'desktop-large': 1600,
	},
	quality: 100,
	provider: 'sanity',
	sanity: {
		projectId: process.env.SANITY_PROJECT_ID,
	}
},
<NuxtImg 
	:src="item.image.assetRef" 
	:alt="item.image.alt"
	sizes="100vw tablet-portrait:80vw"
	loading="eager"
	preload
	v-if="item.image?.asset"
/>
<img onerror="this.setAttribute('data-error', 1)" loading="lazy" data-nuxt-img="" sizes="(max-width: 768px) 100vw, 50vw" srcset="https://cdn.sanity.io/images/p1gk0fvo/production/70b843aa5746434e5221595e7ad15d2c3fee6cc5-1500x2250.jpg?w=1&amp;q=100&amp;auto=format 1w, https://cdn.sanity.io/images/p1gk0fvo/production/70b843aa5746434e5221595e7ad15d2c3fee6cc5-1500x2250.jpg?w=2&amp;q=100&amp;auto=format 2w, https://cdn.sanity.io/images/p1gk0fvo/production/70b843aa5746434e5221595e7ad15d2c3fee6cc5-1500x2250.jpg?w=384&amp;q=100&amp;auto=format 384w, https://cdn.sanity.io/images/p1gk0fvo/production/70b843aa5746434e5221595e7ad15d2c3fee6cc5-1500x2250.jpg?w=768&amp;q=100&amp;auto=format 768w" src="https://cdn.sanity.io/images/p1gk0fvo/production/70b843aa5746434e5221595e7ad15d2c3fee6cc5-1500x2250.jpg?w=768&amp;q=100&amp;auto=format" data-v-8c679f46="">

richgcook avatar Aug 21 '25 21:08 richgcook