@model SceneEditViewModel @{ static string? FileHref(string? filePath) { if (string.IsNullOrWhiteSpace(filePath)) { return null; } return filePath.StartsWith("http", StringComparison.OrdinalIgnoreCase) ? filePath : filePath.StartsWith("/") ? filePath : !System.IO.Path.IsPathRooted(filePath) ? "/" + filePath.TrimStart('/', '\\') : null; } static bool IsImageAttachment(string? href, string? filePath) { if (string.IsNullOrWhiteSpace(href) || string.IsNullOrWhiteSpace(filePath)) { return false; } var extension = System.IO.Path.GetExtension(filePath); return new[] { ".jpg", ".jpeg", ".png", ".gif", ".webp", ".bmp" } .Contains(extension, StringComparer.OrdinalIgnoreCase); } }
Current attachments @Model.Attachments.Count
@if (Model.StorageUsage is not null) {

Storage used: @Model.StorageUsage.DisplayLabel

} @if (!Model.Attachments.Any()) {

No scene references yet.

} else {
@foreach (var attachment in Model.Attachments) { var href = FileHref(attachment.FilePath); var hasFile = !string.IsNullOrWhiteSpace(attachment.FilePath); var hasImage = IsImageAttachment(href, attachment.FilePath);

@attachment.Title

@attachment.TypeName / @(hasFile ? "Uploaded file" : "External link")

@if (hasImage) { @attachment.Title preview } else { }
@if (!string.IsNullOrWhiteSpace(attachment.Notes)) {

@attachment.Notes

} @if (hasFile) {

@System.IO.Path.GetFileName(attachment.FilePath)

}
@if (!string.IsNullOrWhiteSpace(href)) { Open Download } @if (!string.IsNullOrWhiteSpace(attachment.ExternalUrl)) { Open link }
@Html.AntiForgeryToken()
@Html.AntiForgeryToken()
}
}
Add attachment
@Html.AntiForgeryToken()