Replace YouTube iframe with clickable thumbnail

- Changed YouTube embed URL from embed format to watch format
- Added ThumbnailUrl property to YouTubeVideoEmbedProjection using YouTube's standard thumbnail URL
- Updated MessageGroupTemplate to render thumbnail image with link instead of iframe
- Updated CSS to style thumbnail appropriately
- Updated test to check for anchor link and thumbnail image instead of iframe

Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2026-02-12 09:16:56 +00:00
parent d185363322
commit c3f89c45b1
4 changed files with 32 additions and 7 deletions

View file

@ -181,8 +181,24 @@ public class HtmlEmbedSpecs
); );
// Assert // Assert
var iframeUrl = message.QuerySelector("iframe")?.GetAttribute("src"); var youtubeLink = message
iframeUrl.Should().StartWith("https://www.youtube.com/embed/qOWW4OlgbvE"); .QuerySelectorAll("a")
.FirstOrDefault(e =>
e.GetAttribute("href")?.Contains("youtube.com/watch?v=", StringComparison.Ordinal)
== true
);
youtubeLink.Should().NotBeNull();
youtubeLink?.GetAttribute("href").Should().Contain("qOWW4OlgbvE");
// Check that the thumbnail image exists
var thumbnail = youtubeLink
?.QuerySelectorAll("img")
.FirstOrDefault(e =>
e.GetAttribute("class")?.Contains("chatlog__embed-youtube-thumbnail") == true
);
thumbnail.Should().NotBeNull();
} }
[Fact] [Fact]

View file

@ -2,7 +2,9 @@
public partial record YouTubeVideoEmbedProjection(string VideoId) public partial record YouTubeVideoEmbedProjection(string VideoId)
{ {
public string Url { get; } = $"https://www.youtube.com/embed/{VideoId}"; public string Url { get; } = $"https://www.youtube.com/watch?v={VideoId}";
public string ThumbnailUrl { get; } = $"https://i.ytimg.com/vi/{VideoId}/maxresdefault.jpg";
} }
public partial record YouTubeVideoEmbedProjection public partial record YouTubeVideoEmbedProjection

View file

@ -424,9 +424,14 @@
</div> </div>
} }
@* Video player *@ @* Video thumbnail *@
<div class="chatlog__embed-youtube-container"> <div class="chatlog__embed-youtube-container">
<iframe class="chatlog__embed-youtube" src="@youTubeVideoEmbed.Url" width="400" height="225"></iframe> <a href="@youTubeVideoEmbed.Url">
@{
var thumbnailUrl = embed.Thumbnail?.ProxyUrl ?? embed.Thumbnail?.Url ?? youTubeVideoEmbed.ThumbnailUrl;
}
<img class="chatlog__embed-youtube-thumbnail" src="@await ResolveAssetUrlAsync(thumbnailUrl)" alt="YouTube video thumbnail" loading="lazy" onerror="this.style.visibility='hidden'" data-canonical-url="@thumbnailUrl">
</a>
</div> </div>
</div> </div>
</div> </div>

View file

@ -711,9 +711,11 @@
margin-top: 0.6rem; margin-top: 0.6rem;
} }
.chatlog__embed-youtube { .chatlog__embed-youtube-thumbnail {
border: 0; max-width: 400px;
max-height: 225px;
border-radius: 3px; border-radius: 3px;
cursor: pointer;
} }
.chatlog__sticker { .chatlog__sticker {