From 7f5179efcac065ac902a1b84f03d610a9f9e5f63 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Sun, 19 May 2024 09:13:53 -0500 Subject: [PATCH] renderAttachment: guess mime from url --- src/views/mastodon/attachments.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/views/mastodon/attachments.ts b/src/views/mastodon/attachments.ts index 0b1b8eb..2d65804 100644 --- a/src/views/mastodon/attachments.ts +++ b/src/views/mastodon/attachments.ts @@ -1,9 +1,12 @@ +import { getUrlMediaType } from '@/utils/media.ts'; + /** Render Mastodon media attachment. */ function renderAttachment(media: { id?: string; data: string[][] }) { const { id, data: tags } = media; - const m = tags.find(([name]) => name === 'm')?.[1]; const url = tags.find(([name]) => name === 'url')?.[1]; + + const m = tags.find(([name]) => name === 'm')?.[1] ?? getUrlMediaType(url!); const alt = tags.find(([name]) => name === 'alt')?.[1]; const cid = tags.find(([name]) => name === 'cid')?.[1]; const dim = tags.find(([name]) => name === 'dim')?.[1];