Skip to content

Commit 2497bd1

Browse files
committed
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
1 parent d4f18d1 commit 2497bd1

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

apps/frontend/src/components/media/new.uploader.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ export function useUppyUploader(props: {
8888
// Expand generic types to specific ones
8989
const expandedTypes = allowedTypes.flatMap((type) => {
9090
if (type === 'image/*') {
91-
return ['image/png', 'image/jpeg', 'image/jpg', 'image/gif'];
91+
return ['image/png', 'image/jpeg', 'image/jpg', 'image/gif', 'image/webp'];
9292
}
9393
if (type === 'video/*') {
9494
return ['video/mp4', 'video/mpeg'];

libraries/helpers/src/utils/valid.url.path.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,15 @@ export class ValidUrlExtension implements ValidatorConstraintInterface {
1212
!!text?.split?.('?')?.[0].endsWith('.jpg') ||
1313
!!text?.split?.('?')?.[0].endsWith('.jpeg') ||
1414
!!text?.split?.('?')?.[0].endsWith('.gif') ||
15+
!!text?.split?.('?')?.[0].endsWith('.webp') ||
1516
!!text?.split?.('?')?.[0].endsWith('.mp4')
1617
);
1718
}
1819

1920
defaultMessage(args: ValidationArguments) {
2021
// here you can provide default error message if validation failed
2122
return (
22-
'File must have a valid extension: .png, .jpg, .jpeg, .gif, or .mp4'
23+
'File must have a valid extension: .png, .jpg, .jpeg, .gif, .webp, or .mp4'
2324
);
2425
}
2526
}

0 commit comments

Comments
 (0)