From 2497bd139d4441fd816e08824f5660ceee8f2b8a Mon Sep 17 00:00:00 2001 From: fer-r Date: Fri, 26 Dec 2025 03:10:49 +0100 Subject: [PATCH] feat: add WebP image upload support - Added image/webp to the list of allowed MIME types in the file uploader preprocessor - Added .webp extension validation in ValidUrlExtension validator - Updated error message to include .webp in the list of valid extensions Closes #1055 --- apps/frontend/src/components/media/new.uploader.tsx | 2 +- libraries/helpers/src/utils/valid.url.path.ts | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/apps/frontend/src/components/media/new.uploader.tsx b/apps/frontend/src/components/media/new.uploader.tsx index be292f37..f5d5e2b5 100644 --- a/apps/frontend/src/components/media/new.uploader.tsx +++ b/apps/frontend/src/components/media/new.uploader.tsx @@ -88,7 +88,7 @@ export function useUppyUploader(props: { // Expand generic types to specific ones const expandedTypes = allowedTypes.flatMap((type) => { if (type === 'image/*') { - return ['image/png', 'image/jpeg', 'image/jpg', 'image/gif']; + return ['image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/webp']; } if (type === 'video/*') { return ['video/mp4', 'video/mpeg']; diff --git a/libraries/helpers/src/utils/valid.url.path.ts b/libraries/helpers/src/utils/valid.url.path.ts index fbcc0069..a9021ea5 100644 --- a/libraries/helpers/src/utils/valid.url.path.ts +++ b/libraries/helpers/src/utils/valid.url.path.ts @@ -12,6 +12,7 @@ export class ValidUrlExtension implements ValidatorConstraintInterface { !!text?.split?.('?')?.[0].endsWith('.jpg') || !!text?.split?.('?')?.[0].endsWith('.jpeg') || !!text?.split?.('?')?.[0].endsWith('.gif') || + !!text?.split?.('?')?.[0].endsWith('.webp') || !!text?.split?.('?')?.[0].endsWith('.mp4') ); } @@ -19,7 +20,7 @@ export class ValidUrlExtension implements ValidatorConstraintInterface { defaultMessage(args: ValidationArguments) { // here you can provide default error message if validation failed return ( - 'File must have a valid extension: .png, .jpg, .jpeg, .gif, or .mp4' + 'File must have a valid extension: .png, .jpg, .jpeg, .gif, .webp, or .mp4' ); } }