T.Trinks
T.Trinks

Reputation: 1

Next.js Image – Set format for specific img / url

The Next.js image component is normally choosing the best possible format for an images (avif, webm etc.) by accepted format-types of the browser. In my case i need to have the best possible format (avif) for most images except some gallery images that need to be jpeg.

I tried to set the format (jpg) for a specific image/url but nothing worked yet.

Is there a possibility to specify the format. Like a query for the optimization "/_next/image?url=" + img-url + "?fm=jpg" or something like that? Or a special way in the next/config?

Upvotes: 0

Views: 1424

Answers (2)

skndstry
skndstry

Reputation: 671

You can use a custom loader for images that need to be in a specific format. If you combine this with a service like Imgix you can still request specific image sizes/crops/etc for your assets.

Upvotes: 1

Jonathan Wieben
Jonathan Wieben

Reputation: 671

There is an unoptimized setting that can be configured globally or per image (https://nextjs.org/docs/api-reference/next/image#unoptimized).

Upvotes: 0

Related Questions