mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2026-01-28 22:01:55 +00:00
Use proxy URL for generic image embeds
This commit is contained in:
@@ -23,6 +23,10 @@ public partial record Embed(
|
||||
EmbedVideo? Video,
|
||||
EmbedFooter? Footer)
|
||||
{
|
||||
// Embeds can only have one image according to the API model,
|
||||
// but the client can render multiple images in some cases.
|
||||
public EmbedImage? Image => Images.FirstOrDefault();
|
||||
|
||||
public SpotifyTrackEmbedProjection? TryGetSpotifyTrack() =>
|
||||
SpotifyTrackEmbedProjection.TryResolve(this);
|
||||
|
||||
|
||||
@@ -150,11 +150,10 @@ internal class JsonMessageWriter : MessageWriter
|
||||
await WriteEmbedImageAsync(embed.Thumbnail, cancellationToken);
|
||||
}
|
||||
|
||||
// Legacy: backwards-compatibility for old embeds with a single image
|
||||
if (embed.Images.Count > 0)
|
||||
if (embed.Image is not null)
|
||||
{
|
||||
_writer.WritePropertyName("image");
|
||||
await WriteEmbedImageAsync(embed.Images[0], cancellationToken);
|
||||
await WriteEmbedImageAsync(embed.Image, cancellationToken);
|
||||
}
|
||||
|
||||
if (embed.Footer is not null)
|
||||
|
||||
@@ -392,11 +392,11 @@
|
||||
</div>
|
||||
}
|
||||
// Generic image embed
|
||||
else if (embed.Kind == EmbedKind.Image && !string.IsNullOrWhiteSpace(embed.Url))
|
||||
else if (embed.Kind == EmbedKind.Image && !string.IsNullOrWhiteSpace(embed.Image?.Url))
|
||||
{
|
||||
<div class="chatlog__embed">
|
||||
<a href="@await ResolveAssetUrlAsync(embed.Url)">
|
||||
<img class="chatlog__embed-generic-image" src="@await ResolveAssetUrlAsync(embed.Url)" alt="Embedded image" loading="lazy">
|
||||
<a href="@await ResolveAssetUrlAsync(embed.Image.ProxyUrl ?? embed.Image.Url)">
|
||||
<img class="chatlog__embed-generic-image" src="@await ResolveAssetUrlAsync(embed.Image.ProxyUrl ?? embed.Image.Url)" alt="Embedded image" loading="lazy">
|
||||
</a>
|
||||
</div>
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user