Skip to content

Commit

Permalink
allow more filetypes but only compress png/jpeg/webp
Browse files Browse the repository at this point in the history
  • Loading branch information
NoahSaso committed Sep 24, 2024
1 parent 88e2a67 commit f9a5af6
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
8 changes: 7 additions & 1 deletion packages/stateless/components/inputs/ImageDropInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,13 @@ export const ImageDropInput = ({
<FileDropInput
Icon={CloudUploadRounded}
IconHover={CloudDownloadRounded}
allowedMimetypes={['image/png', 'image/jpeg']}
allowedMimetypes={[
'image/png',
'image/jpeg',
'image/gif',
'image/svg',
'image/webp',
]}
className={clsx(className, image && '!outline-solid')}
dragHereOrSelect={
<Trans i18nKey="form.dragImageHereOrClick">
Expand Down
7 changes: 5 additions & 2 deletions packages/stateless/components/inputs/ImageUploadInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,11 @@ export const ImageUploadInput = ({
setUploading(true)

try {
// Compress image to be below 3MB.
if (file.size > 3 * 1024 * 1024) {
// Compress png/jpeg/webp image to be below 3MB.
if (
file.size > 3 * 1024 * 1024 &&
['image/png', 'image/jpeg', 'image/webp'].includes(file.type)
) {
// The image compression library actually returns a Blob, so we need to
// wrap it in a File so that its name and file extension are preserved.
file = new File(
Expand Down

0 comments on commit f9a5af6

Please sign in to comment.