From 5976735af20185cc1b20305ffc61c78485494c67 Mon Sep 17 00:00:00 2001 From: pancakes Date: Wed, 26 Feb 2025 18:14:29 +1000 Subject: [PATCH] [frontend/components] Fallback to detecting attachment type by filename extension --- .../Components/AttachmentComponent.razor | 7 ++++--- Iceshrimp.Frontend/Core/Miscellaneous/Constants.cs | 11 +++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 Iceshrimp.Frontend/Core/Miscellaneous/Constants.cs diff --git a/Iceshrimp.Frontend/Components/AttachmentComponent.razor b/Iceshrimp.Frontend/Components/AttachmentComponent.razor index 57c056f6..f035f3e8 100644 --- a/Iceshrimp.Frontend/Components/AttachmentComponent.razor +++ b/Iceshrimp.Frontend/Components/AttachmentComponent.razor @@ -1,4 +1,5 @@ @using Iceshrimp.Assets.PhosphorIcons +@using Iceshrimp.Frontend.Core.Miscellaneous @using Iceshrimp.Frontend.Core.Services @using Iceshrimp.Frontend.Localization @using Iceshrimp.Shared.Schemas.Web @@ -7,7 +8,7 @@ @inject IStringLocalizer Loc;
- @if (Attachment.ContentType.StartsWith("image")) + @if (Attachment.ContentType.StartsWith("image") || Constants.CommonImageExtensions.Any(e => Attachment.FileName.EndsWith(e))) { @Attachment.AltText @@ -24,11 +25,11 @@ // { // TODO: Module player // } - else if (Attachment.ContentType.StartsWith("audio")) + else if (Attachment.ContentType.StartsWith("audio") || Constants.CommonAudioExtensions.Any(e => Attachment.FileName.EndsWith(e))) { } - else if (Attachment.ContentType.StartsWith("video")) + else if (Attachment.ContentType.StartsWith("video") || Constants.CommonVideoExtensions.Any(e => Attachment.FileName.EndsWith(e))) {