From 2dd0742c1c544c763b06df56deacb57ee95f3f9c Mon Sep 17 00:00:00 2001 From: Alexey Golub Date: Sun, 3 Mar 2019 20:20:01 +0200 Subject: [PATCH] Fix video attachments getting rendered as images Fixes #120 --- DiscordChatExporter.Core/Models/Attachment.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/DiscordChatExporter.Core/Models/Attachment.cs b/DiscordChatExporter.Core/Models/Attachment.cs index f8d6336..a92c235 100644 --- a/DiscordChatExporter.Core/Models/Attachment.cs +++ b/DiscordChatExporter.Core/Models/Attachment.cs @@ -1,4 +1,5 @@ -using ByteSizeLib; +using System; +using ByteSizeLib; namespace DiscordChatExporter.Core.Models { @@ -14,10 +15,14 @@ namespace DiscordChatExporter.Core.Models public int? Height { get; } - public bool IsImage => Width != null; - public string FileName { get; } + public bool IsImage => FileName.EndsWith(".jpg", StringComparison.OrdinalIgnoreCase) || + FileName.EndsWith(".jpeg", StringComparison.OrdinalIgnoreCase) || + FileName.EndsWith(".png", StringComparison.OrdinalIgnoreCase) || + FileName.EndsWith(".gif", StringComparison.OrdinalIgnoreCase) || + FileName.EndsWith(".bmp", StringComparison.OrdinalIgnoreCase); + public ByteSize FileSize { get; } public Attachment(string id, int? width, int? height, string url, string fileName, ByteSize fileSize)