mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-07-21 04:56:19 +02:00
Inline thumbnail URL logic directly into attributes
- Remove GetThumbnailUrl method from YouTubeVideoEmbedProjection - Remove local variables from template - Put coalescing logic directly in src and data-canonical-url attributes Co-authored-by: Tyrrrz <1935960+Tyrrrz@users.noreply.github.com>
This commit is contained in:
@@ -6,9 +6,6 @@ public partial record YouTubeVideoEmbedProjection(string VideoId)
|
|||||||
|
|
||||||
// Using hqdefault.jpg which is guaranteed to exist for all YouTube videos
|
// Using hqdefault.jpg which is guaranteed to exist for all YouTube videos
|
||||||
public string ThumbnailUrl { get; } = $"https://i.ytimg.com/vi/{VideoId}/hqdefault.jpg";
|
public string ThumbnailUrl { get; } = $"https://i.ytimg.com/vi/{VideoId}/hqdefault.jpg";
|
||||||
|
|
||||||
public string GetThumbnailUrl(Embed embed) =>
|
|
||||||
embed.Thumbnail?.ProxyUrl ?? embed.Thumbnail?.Url ?? ThumbnailUrl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public partial record YouTubeVideoEmbedProjection
|
public partial record YouTubeVideoEmbedProjection
|
||||||
|
|||||||
@@ -427,11 +427,7 @@
|
|||||||
@* Video thumbnail *@
|
@* Video thumbnail *@
|
||||||
<div class="chatlog__embed-youtube-container">
|
<div class="chatlog__embed-youtube-container">
|
||||||
<a href="@youTubeVideoEmbed.Url">
|
<a href="@youTubeVideoEmbed.Url">
|
||||||
@{
|
<img class="chatlog__embed-youtube-thumbnail" src="@await ResolveAssetUrlAsync(embed.Thumbnail?.ProxyUrl ?? embed.Thumbnail?.Url ?? youTubeVideoEmbed.ThumbnailUrl)" alt="YouTube video thumbnail" loading="lazy" onerror="this.style.visibility='hidden'" data-canonical-url="@(embed.Thumbnail?.Url ?? youTubeVideoEmbed.ThumbnailUrl)">
|
||||||
var thumbnailUrl = youTubeVideoEmbed.GetThumbnailUrl(embed);
|
|
||||||
var thumbnailCanonicalUrl = 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="@thumbnailCanonicalUrl">
|
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user