1
0
Fork 0
mirror of https://github.com/plankanban/planka.git synced 2025-07-19 13:19:44 +02:00

fix: Set limit for displaying attachment content

Closes #1141
This commit is contained in:
Maksim Eltyshev 2025-05-26 14:35:23 +02:00
parent a7c1d4ca11
commit 978b2a7402
4 changed files with 21 additions and 7 deletions

View file

@ -11,6 +11,7 @@ import { useTranslation } from 'react-i18next';
import { Item as GalleryItem } from 'react-photoswipe-gallery';
import selectors from '../../../selectors';
import Config from '../../../constants/Config';
import Encodings from '../../../constants/Encodings';
import { AttachmentTypes } from '../../../constants/Enums';
import ItemContent from './ItemContent';
@ -70,13 +71,21 @@ const Item = React.memo(({ id, isVisible }) => {
break;
default:
if (attachment.data.encoding === Encodings.UTF8) {
content = (
<ContentViewer
src={attachment.data.url}
filename={attachment.data.filename}
className={classNames(styles.content, styles.contentViewer)}
/>
);
if (attachment.data.sizeInBytes <= Config.MAX_SIZE_IN_BYTES_TO_DISPLAY_CONTENT) {
content = (
<ContentViewer
src={attachment.data.url}
filename={attachment.data.filename}
className={classNames(styles.content, styles.contentViewer)}
/>
);
} else {
content = (
<span className={classNames(styles.content, styles.contentError)}>
{t('common.contentOfThisAttachmentIsTooBigToDisplay')}
</span>
);
}
} else {
content = (
<span className={classNames(styles.content, styles.contentError)}>