mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-02-14 15:53:30 -07: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:
parent
08b03cf27e
commit
c28ec13524
|
|
@ -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>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue