im HTML referenziert wird
- string? linked = mainImages.FirstOrDefault(u => htmlFileNames.Contains(GetFileNameFromUrl(u).ToLowerInvariant()));
-
- if (linked != null)
- {
- result.Add(linked);
- var skipped = mainImages.Where(u => u != linked).ToList();
- foreach (var s in skipped)
- Console.WriteLine($" [Bild] Übersprungen (nicht verlinkt): {Path.GetFileName(new Uri(s).AbsolutePath)}");
- }
- else
- {
- // Keine Verlinkung: Original (ohne -scaled) bevorzugen
- var preferred = mainImages.FirstOrDefault(u => !u.Contains("-scaled")) ?? mainImages[0];
- result.Add(preferred);
- var skipped = mainImages.Where(u => u != preferred).ToList();
- foreach (var s in skipped)
- Console.WriteLine($" [Bild] Übersprungen (scaled): {Path.GetFileName(new Uri(s).AbsolutePath)}");
- }
- }
- }
-
- return result;
- }
-
private static void MarkProcessed(int wpId, string? wpSlug = null)
{
ProcessedPosts.Add(wpId);
diff --git a/GhostImageManager/Components/Pages/Images.razor b/GhostImageManager/Components/Pages/Images.razor
index 9c764ee..925d29d 100644
--- a/GhostImageManager/Components/Pages/Images.razor
+++ b/GhostImageManager/Components/Pages/Images.razor
@@ -60,6 +60,16 @@ else
}
+
+
+
+
Gefiltert: @_filteredImages.Count von @_allImages.Count
- @if (!string.IsNullOrWhiteSpace(_authorFilter) || !string.IsNullOrWhiteSpace(_themeFilter))
+ @if (!string.IsNullOrWhiteSpace(_authorFilter) || !string.IsNullOrWhiteSpace(_themeFilter) || !string.IsNullOrWhiteSpace(_categoryFilter))
{
-
- (@(!string.IsNullOrWhiteSpace(_authorFilter) ? "Autor" : "")
- @(!string.IsNullOrWhiteSpace(_authorFilter) && !string.IsNullOrWhiteSpace(_themeFilter) ? " + " : "")
- @(!string.IsNullOrWhiteSpace(_themeFilter) ? "Thema" : ""))
-
+
+ @if (!string.IsNullOrWhiteSpace(_authorFilter)): @:Autor
+ @if (!string.IsNullOrWhiteSpace(_themeFilter)): @:Thema
+ @if (!string.IsNullOrWhiteSpace(_categoryFilter)): @:Kategorie
+
}
@@ -437,6 +448,7 @@ else
private int _orphanedCount;
private int _featureCount;
private int _contentCount;
+ private string _categoryFilter = "";
private GhostImage? _selectedImage;
private bool _showReplaceDialog;
@@ -518,6 +530,7 @@ else
_orphanedCount = _allImages.Count(i => i.IsOrphaned);
_featureCount = _allImages.Count(i => i.UsedInPosts.Any(r => r.IsFeatureImage));
_contentCount = _allImages.Count(i => i.UsedInPosts.Any(r => r.IsInContent));
+ _categoryCount = _allImages.Count(i => !string.IsNullOrEmpty(i.Category));
}
private List FilteredImages => _filteredImages;
@@ -538,8 +551,16 @@ else
.OrderBy(t => t)
.ToList();
+ private List> AvailableCategories => _allImages
+ .Where(i => !string.IsNullOrEmpty(i.Category))
+ .GroupBy(i => i.Category!)
+ .Select(g => new KeyValuePair(g.Key, g.Key))
+ .OrderBy(kvp => kvp.Value)
+ .ToList();
+
private int GetAuthorCount(string authorId) => _allImages.Count(i => i.AuthorId == authorId);
private int GetThemeCount(string theme) => _allImages.Count(i => i.Theme == theme);
+ private int GetCategoryCount(string category) => _allImages.Count(i => i.Category == category);
private void ApplyFilters()
{
@@ -558,6 +579,9 @@ else
if (!string.IsNullOrWhiteSpace(_themeFilter))
query = query.Where(i => i.Theme == _themeFilter);
+ if (!string.IsNullOrWhiteSpace(_categoryFilter))
+ query = query.Where(i => i.Category == _categoryFilter);
+
_filteredImages = query.ToList();
StateHasChanged();
}
@@ -566,6 +590,7 @@ else
{
_authorFilter = "";
_themeFilter = "";
+ _categoryFilter = "";
_searchTerm = "";
_currentFilter = ImageFilter.All;
ApplyFilters();
@@ -858,6 +883,7 @@ else
All,
Feature,
Content,
- Orphaned
+ Orphaned,
+ Category
}
}
diff --git a/GhostImageManager/Data/AppDbContext.cs b/GhostImageManager/Data/AppDbContext.cs
index 07b8a97..9f5ed1a 100644
--- a/GhostImageManager/Data/AppDbContext.cs
+++ b/GhostImageManager/Data/AppDbContext.cs
@@ -36,6 +36,9 @@ public class AppDbContext : DbContext
entity.Property(e => e.Iso).HasMaxLength(50);
entity.Property(e => e.FocalLength).HasMaxLength(50);
entity.Property(e => e.Theme).HasMaxLength(500);
+ entity.Property(e => e.Category).HasMaxLength(200);
+ entity.Property(e => e.CategorySecondary).HasMaxLength(200);
+ entity.Property(e => e.Keywords).HasMaxLength(500);
});
}
}
diff --git a/GhostImageManager/Data/ManagedImage.cs b/GhostImageManager/Data/ManagedImage.cs
index 057d2f3..f869acb 100644
--- a/GhostImageManager/Data/ManagedImage.cs
+++ b/GhostImageManager/Data/ManagedImage.cs
@@ -41,4 +41,10 @@ public class ManagedImage
public DateTime FirstSeen { get; set; }
public DateTime LastUpdated { get; set; }
public bool IsOrphaned { get; set; }
+
+ // Kategorien / Tags
+ public string? Category { get; set; } // Primäre Kategorie
+ public string? CategorySecondary { get; set; } // Sekundäre Kategorie (falls mehrere)
+ public bool HasMultipleCategories { get; set; }
+ public string? Keywords { get; set; } // HTML Meta Keywords
}
diff --git a/WPPlugin/rbrExportRestApi.php b/WPPlugin/rbrExportRestApi.php
index 970755d..d6beec6 100644
--- a/WPPlugin/rbrExportRestApi.php
+++ b/WPPlugin/rbrExportRestApi.php
@@ -175,16 +175,26 @@ function rbr_get_post_details_with_media($data) {
// Duplikate entfernen
$unique_media = array_values(array_unique($media_urls));
- // 4. Kategorien
+ // 4. Kategorien - bestimme das Primäre (erste Kategorie oder nach slug sortiert)
$categories = array();
+ $primary_category = null;
$cats = get_the_category($post_id);
if (!empty($cats) && !is_wp_error($cats)) {
+ // Sortiere nach term_id (älteste/erste Kategorie wird primär)
+ usort($cats, function($a, $b) {
+ return $a->term_id <=> $b->term_id;
+ });
foreach ($cats as $cat) {
+ $is_primary = ($cat->term_id === $cats[0]->term_id);
$categories[] = array(
- 'id' => intval($cat->term_id),
- 'name' => $cat->name,
- 'slug' => $cat->slug,
+ 'id' => intval($cat->term_id),
+ 'name' => $cat->name,
+ 'slug' => $cat->slug,
+ 'primary' => $is_primary,
);
+ if ($is_primary) {
+ $primary_category = $cat->name;
+ }
}
}
@@ -262,6 +272,7 @@ function rbr_get_post_details_with_media($data) {
),
'featured_image' => $featured_image_url,
'categories' => $categories,
+ 'primary_category' => $primary_category,
'tags' => $tags,
'keywords' => $keywords,
'comments' => $comments,