Nuxt Image does not optimize my images

hey guys, does anyone know why nuxt image doesn't optimize my images? I added the module as per documentation and this is my config:
ssr: false,
nitro: {
static: true,
},
image: {
strapi: {},
format: ["webp", "avif", "png", "jpeg", "jpg", "svg"],
domains: [`${process.env.NUXT_STRAPI_URL}`], // For Strapi-hosted images
provider: "ipx", // For client-side optimization
}
ssr: false,
nitro: {
static: true,
},
image: {
strapi: {},
format: ["webp", "avif", "png", "jpeg", "jpg", "svg"],
domains: [`${process.env.NUXT_STRAPI_URL}`], // For Strapi-hosted images
provider: "ipx", // For client-side optimization
}
<NuxtImg
:src="getStrapiMedia(`${data.hero_image.data.attributes.url}`)"
:alt="data.hero_image.data.attributes.alternativeText"
class="w-full max-w-[339px] sm:max-w-[500px] md:max-w-[1080px] rounded-t-xl rounded-tr-xl"
/>
<NuxtImg
:src="getStrapiMedia(`${data.hero_image.data.attributes.url}`)"
:alt="data.hero_image.data.attributes.alternativeText"
class="w-full max-w-[339px] sm:max-w-[500px] md:max-w-[1080px] rounded-t-xl rounded-tr-xl"
/>
getStrapiMedia returns the full url of the requested media (basically it appends the correct url in the value given if necessary. during the nuxt generate --prerender process there aren't any images been generated in the .output folder (optimized images I mean) and the images showing at the user are the same as they are in the CMS. Most images are .svg and they can be 2 MB worth of size which I do not want that. Any clues why they don't get optimized during the generate process?
6 Replies
danielroe
danielroe3d ago
that's not yet supported (downloading images from a cms during generation)
george.x.r
george.x.r3d ago
@danielroe thank you! does that mean nuxt image only optimizes images that are located in the public folder?
danielroe
danielroe3d ago
yes. it's responsible for the other providers to handle generating a url that is optimised via the url
george.x.r
george.x.r3d ago
so there is no way to optimize images retrieved from Strapi? they must be already optimized when uploaded there?
Cue
Cue3d ago
Let Strapi handle the optimization. Check out the market, lots of plugins.
george.x.r
george.x.r3d ago
yeah I thought the nuxt-image plugin would handle that
Want results from more Discord servers?
Add your server