From 7594a334d8485832f465f2118ce2656c4ece41af Mon Sep 17 00:00:00 2001 From: Tomek Date: Tue, 11 Aug 2026 13:09:16 +0200 Subject: [PATCH] Show image thumbnails for file attachments (#4486) Co-authored-by: Claude Haiku 4.5 --- .changeset/svg-file-attachment-previews.md | 5 +++ .../src/components/DocumentView/File.tsx | 31 +++++++++++++++---- 2 files changed, 30 insertions(+), 6 deletions(-) create mode 100644 .changeset/svg-file-attachment-previews.md diff --git a/.changeset/svg-file-attachment-previews.md b/.changeset/svg-file-attachment-previews.md new file mode 100644 index 000000000..b3e3c166b --- /dev/null +++ b/.changeset/svg-file-attachment-previews.md @@ -0,0 +1,5 @@ +--- +"gitbook": patch +--- + +Show image thumbnails, including SVG previews, for file attachments on published sites. diff --git a/packages/gitbook/src/components/DocumentView/File.tsx b/packages/gitbook/src/components/DocumentView/File.tsx index 1f4ac18dd..f3187c558 100644 --- a/packages/gitbook/src/components/DocumentView/File.tsx +++ b/packages/gitbook/src/components/DocumentView/File.tsx @@ -1,12 +1,12 @@ -import { type DocumentBlockFile, SiteInsightsLinkPosition } from '@gitbook/api'; - import { t } from '@/intl/translate'; import { getSimplifiedContentType } from '@/lib/files'; import { resolveContentRefInDocument } from '@/lib/references'; +import { type DocumentBlockFile, SiteInsightsLinkPosition } from '@gitbook/api'; import { getSpaceLanguage } from '@/intl/server'; import { Button, Link } from '../primitives'; import { DownloadButton } from '../primitives/DownloadButton'; +import { Image } from '../utils'; import type { BlockProps } from './Block'; import { Caption } from './Caption'; import { FileIcon } from './FileIcon'; @@ -42,9 +42,24 @@ export async function File(props: BlockProps) { return (
-
- -
{getHumanFileSize(file.size)}
+
+ {contentType === 'image' ? ( + {file.name} + ) : ( + + )}
@@ -57,7 +72,11 @@ export async function File(props: BlockProps) { {file.name}
-
{contentType}
+
+ {contentType + ? `${contentType} ยท ${getHumanFileSize(file.size)}` + : getHumanFileSize(file.size)} +