From 4b1c9660be66a9c292dbd529657d468f768a1c45 Mon Sep 17 00:00:00 2001 From: quentinmay <73214439+quentinmay@users.noreply.github.com> Date: Tue, 15 Jun 2021 07:19:19 -0700 Subject: [PATCH] Render YouTube iframe for applicable video embeds (#607) --- .../Exporting/Writers/Html/Core.css | 4 +++ .../Writers/Html/MessageGroupTemplate.cshtml | 26 ++++++++++++++----- 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/DiscordChatExporter.Core/Exporting/Writers/Html/Core.css b/DiscordChatExporter.Core/Exporting/Writers/Html/Core.css index ba6eea6..b7eef66 100644 --- a/DiscordChatExporter.Core/Exporting/Writers/Html/Core.css +++ b/DiscordChatExporter.Core/Exporting/Writers/Html/Core.css @@ -458,6 +458,10 @@ img { border-radius: 3px; } +.chatlog__embed-youtube-container { + margin-top: 0.6em; +} + .chatlog__embed-image-container { margin-top: 0.6em; } diff --git a/DiscordChatExporter.Core/Exporting/Writers/Html/MessageGroupTemplate.cshtml b/DiscordChatExporter.Core/Exporting/Writers/Html/MessageGroupTemplate.cshtml index 3c154c9..0f3c47f 100644 --- a/DiscordChatExporter.Core/Exporting/Writers/Html/MessageGroupTemplate.cshtml +++ b/DiscordChatExporter.Core/Exporting/Writers/Html/MessageGroupTemplate.cshtml @@ -214,8 +214,19 @@ } } + @if (!string.IsNullOrWhiteSpace(embed.Url) && embed.Url.IndexOf("youtube.com/watch?v=") != -1) + { - @if (!string.IsNullOrWhiteSpace(embed.Description)) + if (embed.Thumbnail is not null && !string.IsNullOrWhiteSpace(embed.Thumbnail.Url)) + { +
+ +
+ } + } + else if (!string.IsNullOrWhiteSpace(embed.Description)) {
@Raw(FormatEmbedMarkdown(embed.Description))
@@ -251,11 +262,14 @@ @if (embed.Thumbnail is not null && !string.IsNullOrWhiteSpace(embed.Thumbnail.Url)) { -
- - Thumbnail - -
+ if (string.IsNullOrWhiteSpace(embed.Url) || embed.Url.IndexOf("youtube.com/watch?v=") == -1) + { +
+ + Thumbnail + +
+ } }