Saisonfotos am Foto statt am Erscheinungsbild

Ein Foto gehoert zu keinem (ganzjaehrig) oder mehreren Erscheinungsbildern und
erscheint nur dort, vor den ganzjaehrigen Fotos. Bausteine waehlen "automatisch"
oder eine eigene Auswahl; Titelbereich und Abschluss zeigen das erste passende
Foto ihrer Liste. Titelbild und "Bilder je Baustein" des Erscheinungsbilds werden
in die Bausteine uebernommen und entfallen dort.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Opus 5.5 committed 2026-10-29 18:53:56 +01:00
1 parent d02f3e05c7
commit 791786ed3e
21 files changed
+449 -235

No files matched your search

+13 -24
View File
@@ -95,35 +95,24 @@ public function text(string $key, ?string $fallback = null): ?string
return $this->appearance?->override($key) ?? $fallback;
}
public function heroPhoto(?Photo $fallback = null): ?Photo
{
return $this->appearance?->heroPhoto ?? $fallback;
}
/**
* Photo ids the active appearance sets for a slot of a placed section ("Bilder je Baustein").
* Picture for link previews (social media, messengers) and search engines: the first photo of the page's
* title area that fits the season, else an automatic photo of the apartment.
*
* @return list<int>
* @param list<array<string, mixed>> $sections the page's placed sections
*/
public function sectionPhotoIds(?string $sectionId, string $slot): array
public function sharePhoto(array $sections = []): ?Photo
{
if (blank($sectionId) || $this->appearance === null) {
return [];
}
$chosen = collect($sections)
->filter(fn (array $section): bool => ($section['type'] ?? null) === 'hero')
->flatMap(fn (array $section): array => (array) ($section['data']['photo_ids'] ?? []))
->map(fn ($id): int => (int) $id)
->all();
$photos = Photo::query()->published()->whereKey($chosen)->with('media')->get()->keyBy('id');
$first = collect($chosen)->map(fn (int $id): ?Photo => $photos->get($id))
->first(fn (?Photo $photo): bool => $photo?->fitsSeason($this->appearance) ?? false);
$ids = $this->appearance->section_photos[$sectionId][$slot] ?? null;
return array_values(array_map('intval', array_filter((array) $ids)));
}
/**
* Whether seasonal photos replace the automatic photos of a section ('replace') or come first ('prepend').
*/
public function sectionPhotoMode(?string $sectionId): string
{
$mode = $sectionId ? ($this->appearance?->section_photos[$sectionId]['mode'] ?? null) : null;
return $mode === 'prepend' ? 'prepend' : 'replace';
return $first ?? Photo::automatic($this->property(), $this->appearance)->first();
}
public function appearanceKey(): string