is it possible to automatically add width and height attributes?
#1076
Replies: 2 comments
-
|
Not generally, because Nuxt Image cannot know the intrinsic dimensions of every possible image source at compile time. Next can do this for static imports because the imported local file is part of the build graph, so the build step can inspect the image and attach width/height metadata. With Nuxt Image, many common sources are remote URLs, CMS assets, provider URLs, or runtime strings, so there may be nothing available at build time to inspect. The usual approaches are:
For layout stability, the important part is not necessarily automatic attributes; it is making sure the browser knows the intended aspect ratio before the image loads. |
Beta Was this translation helpful? Give feedback.
-
|
@yudin-s Thanks for the insight. As I was reviewing the production build, I was shocked since Nuxt typically brings its own magic. This one really hurts because if you're using Nuxt Studio, editors are not going to define width and height, or figure out aspect ratio for that matter. Even if editors were trained and remembered, this is an extra step their former CMS once provided automatically. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
is it possible to automatically add
widthandheightattributes to the image element?for example the next.js image component is able to do that for static image imports.
Beta Was this translation helpful? Give feedback.
All reactions