nuxt / image

Plug-and-play image optimization for Nuxt applications.
https://image.nuxt.com
MIT License
1.34k stars 270 forks source link

It's possiable to configure the default format for `<NuxtImg>` ? #1464

Open JianJroh opened 2 months ago

JianJroh commented 2 months ago

I have seen https://image.nuxt.com/get-started/configuration#format. But it seems to work only for <NuxtPicture>

adamkasper commented 1 month ago

have you checked the <NuxtImg /> source code? from what I’ve seen, it doesn’t seem like this is possible right now

<NuxtPicture /> has this: https://github.com/nuxt/image/blob/main/src/runtime/components/NuxtPicture.vue#L67

IvanhoeGrozni commented 1 day ago

You actually can do it, but you have to set it per-provider. IPX is NuxtImg's default provider, so this works:

image: {
  ipx: {
    modifiers: {
      format: "avif",
    },
  },
},

But it doesn't support SVG. So any SVG images will also be converted to a AVIF in this case, you can not override it on individual elements like this <NuxtImg format="svg" />, for example. :(