Skip to content

Commit

Permalink
Fix(web-react): Increase image quality of FileUploader image preview
Browse files Browse the repository at this point in the history
  * allow larger base64 image to increase quality of previewed image

refs #DS-1039
  • Loading branch information
literat committed Nov 2, 2023
1 parent 68321dc commit 4a9a203
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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 });
Expand Down

0 comments on commit 4a9a203

Please sign in to comment.