nuxt / image

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

[nuxt3] Feature Request: config option for default `format` & `quality` #657

Open hartmut-co-uk opened 1 year ago

hartmut-co-uk commented 1 year ago

I'd like to configure a default image format for all images via nuxt config:

export default defineNuxtConfig({
    modules: [
        '@nuxt/image-edge'
    ],
    image: {
        // 
        format: "webp",
        quality: "80"
    },
}

Questions

  1. According to configuration, this might be possible via provider specific default modifiers?
  2. Is this the best choice for such basic props as 'format', 'quality'?
  3. Is it also possible (to add) for IPX? (IPXOptions)

Refs

hartmut-co-uk commented 1 year ago

I've tested with following config:

export default defineNuxtConfig({
    modules: [
        '@nuxt/image-edge'
    ],
    image: {
    provider: 'ipx',
    ipx: {
      modifiers: {
        quality: '80',
        format: 'webp',
      }
    }
  }
}

This works just fine and is applied to all nuxt-img as a default, also can be overwritten if required. Though type validation fails.

=> So I think it's actually just a missing type def in IPXOptions?

sungeunl commented 1 year ago

is it working fine ? because ipx options exclude modifiers

hartmut-co-uk commented 1 year ago

at the time of writing it was working, I no longer can confirm the exact version though...

@sungeunl is it not working for you anymore?

madebyfabian commented 1 year ago

I can confirm, still works with "@nuxt/image": "1.0.0-rc.3". But still with a type error.

But:

image: {
  format: ['avif', 'webp', 'jpeg', 'png'],
  provider: 'ipx',
  ipx: {
    // @ts-expect-error https://github.com/nuxt/image/issues/657#issuecomment-1326334555
    modifiers: {
      format: 'avif',
    },
  },
},

So overall, not a good solution I think