Upload webp wrapper logo

Upload webp wrapper

By Elson Vieira

Strapi wrapper to convert image files to webp for any upload provider.

Latest version

v1.0.1

released February 8, 2025

npm install strapi-provider-upload-webp-wrapper

npm version

strapi-provider-upload-webp-wrapper

How it's works

This 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.

Requirements

Strapi > v5.0.0

Installation

# 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-wrapper

Configuration

  • provider defines the name of the provider, in this case strapi-provider-upload-webp-wrapper
  • providerOptions.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 options
  • providerOptions.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.

Provider Configuration

./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.

Submit your content

Share your work with the community and get it listed in the Strapi ecosystem for everyone to discover and use.

Submit
Submit your content