@npm_tentwenty/media-webp-converter
v2.0.0
Published
Bulk-converts existing PNG media library files to WebP in place, preserving every relation, component and dynamic zone reference
Readme
media-webp-converter
Bulk-converts existing PNG media library files to WebP in place, preserving every relation, component and dynamic zone reference.
Unlike upload-time converters (e.g. strapi-plugin-webp-converter), this plugin operates on files already in the media library. It updates each plugin::upload.file row in place (same id), so nothing that references the file — collection types, components, nested components inside dynamic zones — needs to change.
Usage
- Register the plugin in
config/plugins.ts:'media-webp-converter': { enabled: true, config: { concurrency: 3, webpOptions: { nearLossless: true, quality: 80 }, cronEnabled: env.bool('WEBP_CONVERTER_CRON_ENABLED', false), }, }, - Start Strapi and open WebP Converter in the left-hand menu.
- Click Start conversion to scan and convert every
image/pngfile on the currently active upload provider.
Conversions are idempotent — already-converted files are tracked in the plugin's own conversion-log content type and skipped on re-run. Each file's original PNG (and its old responsive formats) is deleted only once its WebP replacement has fully uploaded and the media-library row has been updated to point at it — a failure at any point before then leaves the original completely untouched and the file logged as failed, so there's nothing to roll back.
Development
npm install
npm run watch # rebuild on change; requires yalc for linking into a Strapi project
npm run build # one-off build (what strapi-server.js / strapi-admin.js load from dist/)