To reproduce:
- Add nuxt/image to modules (in config, yarn add, etc)
- Add nuxt/image instance with width and height set
<nuxt-img src="cat.jpg" width="300" height="200" />
Expected behavior:
Image component has a srcset attribute that defines a different image width for 1x and 2x images. On a laptop with 2x DPI, the image should ultimately be requested at 600px (2x DPI x given width).
Expected result:
<img src="cat.jpg" srcset="cat.jpg?w=300 1x, cat.jpg?w=600 2x" />
Actual behavior:
There is no srcset attribute generated. On a laptop with 2x DPI, the image is requested at 300px instead of 600px. As a result, the image produced looks grainy.
Actual result:
<img src="cat.jpg?w=300&h=200" />
Suggested change:
The image component should take the user's DPI into account when requesting images by defining a srcset with density descriptors. Given that mobile devices can have unnecessarily high DPI (e.g. 3x), it may be optimal to cap the DPI at 2x.
To reproduce:
Expected behavior:
Image component has a
srcsetattribute that defines a different image width for 1x and 2x images. On a laptop with 2x DPI, the image should ultimately be requested at 600px (2x DPI x given width).Expected result:
Actual behavior:
There is no
srcsetattribute generated. On a laptop with 2x DPI, the image is requested at 300px instead of 600px. As a result, the image produced looks grainy.Actual result:
Suggested change:
The image component should take the user's DPI into account when requesting images by defining a
srcsetwith density descriptors. Given that mobile devices can have unnecessarily high DPI (e.g. 3x), it may be optimal to cap the DPI at 2x.