From d70a00a8cae2f9a554d060d8ffb3e8ed59fdc5de Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Fri, 28 Feb 2025 10:51:08 -0600 Subject: [PATCH] Expose thumb and image to Attachment view, don't set thumb (since it's redundant with image) --- packages/ditto/utils/upload.ts | 4 ---- packages/ditto/views/mastodon/attachments.ts | 4 +++- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/packages/ditto/utils/upload.ts b/packages/ditto/utils/upload.ts index c55da691..aab84db3 100644 --- a/packages/ditto/utils/upload.ts +++ b/packages/ditto/utils/upload.ts @@ -89,10 +89,6 @@ export async function uploadFile( tags.push(['image', url]); } - if (!thumb) { - tags.push(['thumb', url]); - } - if (!blurhash || !dim) { try { const img = sharp(bytes); diff --git a/packages/ditto/views/mastodon/attachments.ts b/packages/ditto/views/mastodon/attachments.ts index b0d2e49c..1e24e794 100644 --- a/packages/ditto/views/mastodon/attachments.ts +++ b/packages/ditto/views/mastodon/attachments.ts @@ -14,6 +14,8 @@ function renderAttachment( const alt = tags.find(([name]) => name === 'alt')?.[1]; const cid = tags.find(([name]) => name === 'cid')?.[1]; const dim = tags.find(([name]) => name === 'dim')?.[1]; + const image = tags.find(([key]) => key === 'image')?.[1]; + const thumb = tags.find(([key]) => key === 'thumb')?.[1]; const blurhash = tags.find(([name]) => name === 'blurhash')?.[1]; if (!url) return; @@ -34,7 +36,7 @@ function renderAttachment( id: id ?? url, type: getAttachmentType(m ?? ''), url, - preview_url: url, + preview_url: image ?? thumb ?? url, remote_url: null, description: alt ?? '', blurhash: blurhash || null,