Stelle alle CMS-Bilder auf die zentrale Medienverwaltung um.
CI Feature / test (push) Successful in 48s
Deploy Test / test (push) Successful in 44s
Deploy Test / deploy (push) Successful in 37s

- Einstieg, Bild und Text, redaktionelle Karten, Premium-Karten und Abschnittshintergrund speichern die
  Kennung des Mediums (Bildschlüssel image) und lesen über WebsiteMedia; öffentlich nur mit Website-Freigabe,
  in der Redaktionsvorschau sonst das Vorschaubild mit Hinweis.
- Gemeinsame Felder: Medienpicker mit Vorschaubild und Status, Upload direkt über WebsiteIntake, Anzeige des
  gewählten Mediums mit Verweis auf den Medienmanager. Die CMS-eigene Bildauswahl entfällt.
- Frühere CMS-Bilder übernimmt ein Warteschlangen-Job (dedupliziert, nichts gelöscht); website_media_aliases
  ordnet frühere Pfade zu, wirksam erst nach der ersten Website-Freigabe; /medien/cms/ folgt danach der Freigabe.
- Medienansicht nennt die Website-Seiten, die ein Bild verwenden.
- Bewusst geändert: Der Alternativtext gehört zum Medium und ist im Widget nur noch eine optionale Abweichung;
  die Tests zur Alt-Text-Pflicht prüfen jetzt Übernahme und andere Registry-Fehler.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-11-18 22:32:29 +01:00
1 parent 7c63424ea6
commit 053a8d4648
35 files changed
+1170 -164

No files matched your search

+13 -8
View File
@@ -2,7 +2,9 @@
namespace App\Domain\Cms\Sections;
use App\Domain\Cms\Widgets\Support\ImageRefFields;
use App\Domain\Cms\Widgets\Support\PublicMedia;
use App\Domain\Cms\Widgets\WidgetErrors;
use App\Domain\Cms\Widgets\WidgetRegistry;
use Illuminate\Support\Str;
use Illuminate\Validation\ValidationException;
@@ -145,7 +147,7 @@ public function mediaPaths(array $sections): array
foreach ($sections as $section) {
$style = SectionStyle::fromStored($section['style'] ?? []);
if ($style['image'] !== null && PublicMedia::isPublicPath($style['image'])) {
if (is_string($style['image']) && PublicMedia::isPublicPath($style['image'])) {
$paths[] = $style['image'];
}
}
@@ -335,14 +337,17 @@ private function normalizeStyle(array $style, string $prefix, array &$errors): a
$result[$key] = $value;
}
$upload = PublicMedia::fromUploadState($style['_upload'] ?? null);
$image = $upload ?? PublicMedia::fromUploadState($style['image'] ?? null);
if ($result['background'] === 'image') {
if ($image === null) {
$errors["$prefix.style.image"] = ['Bitte ein Hintergrundbild wählen oder hochladen.'];
} elseif (! PublicMedia::isPublicPath($image)) {
$errors["$prefix.style.image"] = ['Das Hintergrundbild liegt nicht im öffentlichen Medienbereich.'];
$widgetErrors = new WidgetErrors;
$refs = ImageRefFields::clean(['image' => $style['image'] ?? null, '_upload' => $style['_upload'] ?? null], $widgetErrors, errorKey: 'image');
$image = $refs['image'];
foreach ($widgetErrors->all() as $messages) {
$errors["$prefix.style.image"] = $messages;
}
if ($image === null && ! isset($errors["$prefix.style.image"])) {
$errors["$prefix.style.image"] = ['Bitte ein Hintergrundbild aus dem Medienmanager wählen oder hochladen.'];
}
$result['image'] = $image;
+7 -5
View File
@@ -3,7 +3,7 @@
namespace App\Domain\Cms\Sections;
use App\Domain\Cms\Widgets\RenderContext;
use App\Domain\Cms\Widgets\Support\PublicMedia;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
use App\Domain\Cms\Widgets\WidgetRenderer;
use Illuminate\Support\HtmlString;
@@ -56,7 +56,7 @@ public function renderAll(array $sections, RenderContext $context): HtmlString
$last = count($rendered) - 1;
foreach ($rendered as $index => $item) {
$html .= $this->renderSection($item['section'], $item['cells'], $index);
$html .= $this->renderSection($item['section'], $item['cells'], $index, $context);
$divider = $item['section']['style']['divider'] ?? 'none';
if ($index < $last && in_array($divider, ['line', 'accent'], true)) {
@@ -71,11 +71,13 @@ public function renderAll(array $sections, RenderContext $context): HtmlString
* @param array<string, mixed> $section
* @param list<array{units: int, html: string}> $cells
*/
private function renderSection(array $section, array $cells, int $index): string
private function renderSection(array $section, array $cells, int $index, RenderContext $context): string
{
$style = SectionStyle::fromStored($section['style'] ?? []);
$columns = SectionLayouts::columns(array_column($cells, 'units'));
$hasImage = $style['background'] === 'image' && $style['image'] !== null && PublicMedia::isPublicPath($style['image']);
// Hintergrundbild aus dem Medienmanager: öffentlich nur mit Website-Freigabe (WebsiteImage → WebsiteMedia).
$imageUrl = $style['background'] === 'image' ? app(WebsiteImage::class)->url($style['image'], $context->preview) : null;
$hasImage = $imageUrl !== null;
$classes = [
'page-section',
@@ -109,7 +111,7 @@ private function renderSection(array $section, array $cells, int $index): string
if ($hasImage) {
// Das Bild des ersten Abschnitts ist meist das größte sichtbare Element und wird nicht verzögert geladen.
$loading = $index === 0 ? 'loading="eager" fetchpriority="high"' : 'loading="lazy"';
$html .= '<img class="page-section-image" src="'.e(PublicMedia::url($style['image'])).'" alt="" '.$loading.' decoding="async"'
$html .= '<img class="page-section-image" src="'.e($imageUrl).'" alt="" '.$loading.' decoding="async"'
.' style="object-position: '.e(SectionStyle::FOCUS_POSITIONS[$style['focus']]).'">';
}
+3 -3
View File
@@ -2,7 +2,7 @@
namespace App\Domain\Cms\Sections;
use App\Domain\Cms\Widgets\Support\PublicMedia;
use App\Domain\Cms\Widgets\Support\WebsiteImage;
/**
* Semantische Abschnittsgestaltung. Jeder Wert ist eine Aufzählung, die auf zentrale Design-Tokens
@@ -134,7 +134,7 @@ public static function fromStored(mixed $style): array
}
}
$result['image'] = $result['background'] === 'image' && is_string($style['image'] ?? null) ? $style['image'] : null;
$result['image'] = $result['background'] === 'image' ? WebsiteImage::normalize($style['image'] ?? null) : null;
return $result;
}
@@ -204,7 +204,7 @@ public static function migrateSpacing(array $sections, bool $byVersion = false):
$rendered = is_array($section['slots'] ?? null) && array_filter($section['slots'], 'is_array') !== [];
$background = is_string($style['background'] ?? null) && isset(self::BACKGROUNDS[$style['background']]) ? $style['background'] : 'default';
if ($background === 'image' && ! PublicMedia::isPublicPath($style['image'] ?? null)) {
if ($background === 'image' && WebsiteImage::normalize($style['image'] ?? null) === null) {
$background = 'default';
}
$divider = in_array($style['divider'] ?? null, ['line', 'accent'], true) ? $style['divider'] : 'none';