By Elson Vieira
Strapi wrapper to convert image files to webp for any upload provider.
released February 8, 2025
npm install strapi-provider-upload-webp-wrapperThis provider only create a wrapper between the uploaded file and another provider, this wrapper convert the image files to webp and then delivery it to the actual provider.
Strapi > v5.0.0
# using yarn
yarn add strapi-provider-upload-webp-wrapper
# using npm
npm install strapi-provider-upload-webp-wrapper --save
# using pnpm
pnpm add strapi-provider-upload-webp-wrapperprovider defines the name of the provider, in this case strapi-provider-upload-webp-wrapperproviderOptions.mimeTypes The mime types that will be converted to webp. if not provide the following formats will be accepted. ['image/png', 'image/jpeg', 'image/jpg']providerOptions.sharpOptions Sharp options: See optionsproviderOptions.redirect is the configuration passed down to the effective provider.See the documentation about using a provider for information on installing and using a provider. To understand how environment variables are used in Strapi, please refer to the documentation about environment variables.
./config/plugins.js or ./config/plugins.ts for TypeScript projects:
module.exports = ({ env }) => ({
// ...
upload: {
config: {
provider: "strapi-provider-upload-webp-wrapper",
providerOptions: {
mimeTypes: ['image/png', 'image/jpeg', 'image/jpg'],
sharpOptions: {
quality: 50,
smartSubsample: true
},
redirect: {
provider: 'local',
providerOptions: { sizeLimit: 2 * 1000 * 1000 }
}
}
},
},
// ...
});This configuration convert the requested mime types to wepb and delivery it to the local provider to be stored.
Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.
Submit
