diff --git a/src/components/posts/view-post/helpers.tsx b/src/components/posts/view-post/helpers.tsx index 3a28baa88..21584bd71 100644 --- a/src/components/posts/view-post/helpers.tsx +++ b/src/components/posts/view-post/helpers.tsx @@ -183,35 +183,38 @@ export const PostCreator: FC = ({ export type PostImageProps = { content: PostContentType | undefined className?: string + withPreview?: boolean } -export const PostImage = React.memo(({ content, className }: PostImageProps) => { - const image = content?.image - const [shouldImageBeCropped, setShouldImageBeCropped] = useState(true) +export const PostImage = React.memo( + ({ content, className, withPreview = true }: PostImageProps) => { + const image = content?.image + const [shouldImageBeCropped, setShouldImageBeCropped] = useState(true) - if (!image || isEmptyStr(image)) return null + if (!image || isEmptyStr(image)) return null - const onImgLoad = (e: any) => { - const img = e.target as HTMLImageElement - const { naturalHeight, naturalWidth } = img - const isTallerThan16By9 = naturalWidth / naturalHeight < 16 / 9 - setShouldImageBeCropped(isTallerThan16By9) - } + const onImgLoad = (e: any) => { + const img = e.target as HTMLImageElement + const { naturalHeight, naturalWidth } = img + const isTallerThan16By9 = naturalWidth / naturalHeight < 16 / 9 + setShouldImageBeCropped(isTallerThan16By9) + } - const wrapperClassName = clsx(className, { - DfPostImagePreviewWrapperCropped: shouldImageBeCropped, - DfPostImagePreviewWrapper: true, - }) - return ( - - ) -}) + const wrapperClassName = clsx(className, { + DfPostImagePreviewWrapperCropped: shouldImageBeCropped, + DfPostImagePreviewWrapper: true, + }) + return ( + + ) + }, +) type PostSummaryProps = { space?: SpaceStruct @@ -256,12 +259,12 @@ const PostContentMemoized = React.memo((props: PostContentMemoizedProps) => { return (
- {withImage && } + {withImage && }