I have added code in config/plugin.js
"image-optimizer": { enabled: true, config: { include: ["jpeg", "jpg", "png"], exclude: ["gif"], formats: ["original", "webp", "avif"], sizes: [ { name: "xs", width: 300, }, { name: "sm", width: 768, }, { name: "md", width: 1280, }, { name: "lg", width: 1920, }, { name: "xl", width: 2840, // Won't create an image larger than the original size withoutEnlargement: true, }, { // Uses original size but still transforms for formats name: "original", }, ], additionalResolutions: [1.5, 3], quality: 70, }, },
also add code on src/extensions/upload/strapi-server.ts
`// ./src/extensions/upload/strapi-server.ts
import imageOptimizerService from "strapi-plugin-image-optimizer/dist/server/services/image-optimizer-service";
module.exports = (plugin) => {
plugin.services["image-manipulation"] = imageOptimizerService;
return plugin;
};`