mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-25 20:24:22 -04:00
Use proxy URL for generic image embeds
This commit is contained in:
parent
6d3adf9fde
commit
8e5269f0ab
3 changed files with 9 additions and 6 deletions
|
@ -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>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue