diff --git a/src/components/Widgets/FileWidget.jsx b/src/components/Widgets/FileWidget.jsx index 19d14fd..502434b 100644 --- a/src/components/Widgets/FileWidget.jsx +++ b/src/components/Widgets/FileWidget.jsx @@ -69,13 +69,18 @@ const FileWidget = (props) => { validationText, } = props; const [isImage, setIsImage] = React.useState(false); + const [imageSRC, setImageSRC] = React.useState(null); const intl = useIntl(); React.useEffect(() => { if (value && imageMimetypes.includes(value['content-type'])) { setIsImage(true); + if (value.download) { + setImageSRC(`${flattenToAppURL(imageSRC)}?id=${Date.now()}`); + } } else { setIsImage(false); + setImageSRC(null); } }, [value]); @@ -102,8 +107,9 @@ const FileWidget = (props) => { const fields = reader.result.match(/^data:(.*);(.*),(.*)$/); if (imageMimetypes.includes(fields[1])) { setIsImage(true); - let imagePreview = document.getElementById(`field-${id}-image`); - imagePreview.src = reader.result; + // let imagePreview = document.getElementById(`field-${id}-image`); + // imagePreview.src = reader.result; + setImageSRC(reader.result); } else { setIsImage(false); } @@ -131,19 +137,20 @@ const FileWidget = (props) => { {({ getRootProps, getInputProps, isDragActive }) => (