mirror of
https://github.com/Tyrrrz/DiscordChatExporter.git
synced 2025-05-27 21:24:12 -04:00
parent
489c786c1e
commit
71876febf8
3 changed files with 7 additions and 5 deletions
|
@ -13,6 +13,7 @@ public partial record Attachment(
|
|||
Snowflake Id,
|
||||
string Url,
|
||||
string FileName,
|
||||
string? Description,
|
||||
int? Width,
|
||||
int? Height,
|
||||
FileSize FileSize) : IHasId
|
||||
|
@ -37,8 +38,9 @@ public partial record Attachment
|
|||
var width = json.GetPropertyOrNull("width")?.GetInt32OrNull();
|
||||
var height = json.GetPropertyOrNull("height")?.GetInt32OrNull();
|
||||
var fileName = json.GetProperty("filename").GetNonNullString();
|
||||
var description = json.GetPropertyOrNull("description")?.GetNonWhiteSpaceStringOrNull();
|
||||
var fileSize = json.GetProperty("size").GetInt64().Pipe(FileSize.FromBytes);
|
||||
|
||||
return new Attachment(id, url, fileName, width, height, fileSize);
|
||||
return new Attachment(id, url, fileName, description, width, height, fileSize);
|
||||
}
|
||||
}
|
|
@ -158,19 +158,19 @@
|
|||
@if (attachment.IsImage)
|
||||
{
|
||||
<a href="@await ResolveUrlAsync(attachment.Url)">
|
||||
<img class="chatlog__attachment-media" src="@await ResolveUrlAsync(attachment.Url)" alt="Image attachment" title="Image: @attachment.FileName (@attachment.FileSize)" loading="lazy">
|
||||
<img class="chatlog__attachment-media" src="@await ResolveUrlAsync(attachment.Url)" alt="@(attachment.Description ?? "Image attachment")" title="Image: @attachment.FileName (@attachment.FileSize)" loading="lazy">
|
||||
</a>
|
||||
}
|
||||
else if (attachment.IsVideo)
|
||||
{
|
||||
<video class="chatlog__attachment-media" controls>
|
||||
<source src="@await ResolveUrlAsync(attachment.Url)" alt="Video attachment" title="Video: @attachment.FileName (@attachment.FileSize)">
|
||||
<source src="@await ResolveUrlAsync(attachment.Url)" alt="@(attachment.Description ?? "Video attachment")" title="Video: @attachment.FileName (@attachment.FileSize)">
|
||||
</video>
|
||||
}
|
||||
else if (attachment.IsAudio)
|
||||
{
|
||||
<audio class="chatlog__attachment-media" controls>
|
||||
<source src="@await ResolveUrlAsync(attachment.Url)" alt="Audio attachment" title="Audio: @attachment.FileName (@attachment.FileSize)">
|
||||
<source src="@await ResolveUrlAsync(attachment.Url)" alt="@(attachment.Description ?? "Audio attachment")" title="Audio: @attachment.FileName (@attachment.FileSize)">
|
||||
</audio>
|
||||
}
|
||||
else
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue