From 4a9a2035e37aa2abee8ddc248147cf58aee39901 Mon Sep 17 00:00:00 2001 From: literat Date: Wed, 1 Nov 2023 15:16:13 +0100 Subject: [PATCH] Fix(web-react): Increase image quality of FileUploader image preview * allow larger base64 image to increase quality of previewed image refs #DS-1039 --- .../FileUploader/FileUploaderAttachment.tsx | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/web-react/src/components/FileUploader/FileUploaderAttachment.tsx b/packages/web-react/src/components/FileUploader/FileUploaderAttachment.tsx index 35e55c6160..1efc5f71ca 100644 --- a/packages/web-react/src/components/FileUploader/FileUploaderAttachment.tsx +++ b/packages/web-react/src/components/FileUploader/FileUploaderAttachment.tsx @@ -6,7 +6,12 @@ import { Icon } from '../Icon'; import AttachmentActionButton from './AttachmentActionButton'; import AttachmentDismissButton from './AttachmentDismissButton'; import AttachmentImagePreview from './AttachmentImagePreview'; -import { DEFAULT_BUTTON_LABEL, DEFAULT_EDIT_BUTTON_LABEL, DEFAULT_ICON_NAME } from './constants'; +import { + DEFAULT_BUTTON_LABEL, + DEFAULT_EDIT_BUTTON_LABEL, + DEFAULT_ICON_NAME, + IMAGE_PREVIEW_BASE64_MAX_WIDTH, +} from './constants'; import { useFileUploaderAttachment } from './useFileUploaderAttachment'; import { useFileUploaderStyleProps } from './useFileUploaderStyleProps'; import { image2Base64Preview } from './utils'; @@ -50,7 +55,9 @@ const FileUploaderAttachment = (props: SpiritFileUploaderAttachmentProps) => { const onEditHandler = (event: MouseEvent) => onEdit && onEdit(event, file); if (isFileImage) { - image2Base64Preview(file, 100, (compressedDataURL) => setImagePreview(compressedDataURL)); + image2Base64Preview(file, IMAGE_PREVIEW_BASE64_MAX_WIDTH, (compressedDataURL) => + setImagePreview(compressedDataURL), + ); } useFileUploaderAttachment({ attachmentRef, file, name, meta, onError });