Wp2ghost/GhostImageManager/Models/GhostImage.cs
2026-10-14 19:12:29 +02:00

63 lines
2.2 KiB
C#

namespace GhostImageManager.Models;
public class GhostImage
{
public int? ManagedImageId { get; set; }
public string Url { get; set; } = "";
public string FileName { get; set; } = "";
public string RelativePath { get; set; } = "";
public string FilePath { get; set; } = "";
public long FileSize { get; set; }
public DateTime LastModified { get; set; }
public int Width { get; set; }
public int Height { get; set; }
public bool IsOrphaned { get; set; } = true;
public List<PostReference> UsedInPosts { get; set; } = new();
// Ghost legt beim Upload neben "bild.jpg" die unkomprimierte Kopie "bild_o.jpg" ab.
// Diese wird nie in Posts referenziert; OriginalOf enthält den Dateinamen des zugehörigen Bildes.
public bool IsOriginal { get; set; }
public string? OriginalOf { get; set; }
public bool CanDelete => IsOrphaned || IsOriginal;
// Aus der Datenbank
public string? AuthorId { get; set; }
public string? AuthorName { get; set; }
public string? Theme { get; set; }
public string? Category { get; set; }
public DateTime? CaptureDate { get; set; }
// EXIF
public string? CameraMake { get; set; }
public string? CameraModel { get; set; }
public string? Lens { get; set; }
public string? Aperture { get; set; }
public string? ShutterSpeed { get; set; }
public string? Iso { get; set; }
public string? FocalLength { get; set; }
public string FormattedFileSize => FileSize switch
{
>= 1024 * 1024 => $"{FileSize / (1024.0 * 1024.0):F2} MB",
>= 1024 => $"{FileSize / 1024.0:F2} KB",
_ => $"{FileSize} B"
};
public string Dimensions => Width > 0 && Height > 0 ? $"{Width}x{Height}" : "n/a";
public string CameraDisplay => string.IsNullOrEmpty(CameraModel)
? "n/a"
: $"{CameraMake} {CameraModel}".Trim();
public string ExifSummary => $"{Aperture ?? "-"} | {ShutterSpeed ?? "-"} | ISO {Iso ?? "-"} | {FocalLength ?? "-"}";
}
public class PostReference
{
public string PostId { get; set; } = "";
public string Title { get; set; } = "";
public string Slug { get; set; } = "";
public bool IsFeatureImage { get; set; }
public bool IsInContent { get; set; }
}