Wähle das Vorschaubild am Medium und nutze es als Standard in der Anzeige und in Modulen.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
f86032cb5f
commit
8e77defaca
18 files changed
+664
-26
No files matched your search
@@ -645,17 +645,122 @@ public function cover(Composition $composition, array $members): array
|
||||
return ['url' => $own, 'note' => null, 'own' => true];
|
||||
}
|
||||
|
||||
$films = $this->filmPictures($members);
|
||||
$picture = $this->suggestPicture($members);
|
||||
|
||||
if (count($films) === 1) {
|
||||
if ($picture === null) {
|
||||
return ['url' => null, 'note' => null, 'own' => false];
|
||||
}
|
||||
|
||||
return [
|
||||
'url' => $this->cardUrl($picture['kind'], $picture['subject'], 'vorschau/gesetzt'),
|
||||
'note' => $picture['note'],
|
||||
'own' => false,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Das eigene Titelbild, sonst das erste Vorschaubild aus dem freigegebenen Aufbau.
|
||||
*
|
||||
* @return array{kind: string, subject: int, alt: string, note: string}|null
|
||||
*/
|
||||
public function visiblePicture(Composition $composition, ?CompositionVersion $version): ?array
|
||||
{
|
||||
if ($this->cardUrl('komposition', $composition->id, $composition->thumbnail_path) !== null) {
|
||||
return [
|
||||
'url' => $films[0]['image'],
|
||||
'note' => 'Vorschlag aus dem Film '.$films[0]['title'],
|
||||
'own' => false,
|
||||
'kind' => 'komposition',
|
||||
'subject' => $composition->id,
|
||||
'alt' => filled($composition->thumbnail_alt) ? (string) $composition->thumbnail_alt : $this->compositionTitle($composition),
|
||||
'note' => '',
|
||||
];
|
||||
}
|
||||
|
||||
return ['url' => null, 'note' => null, 'own' => false];
|
||||
if ($version === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
$version->loadMissing('members');
|
||||
$members = [];
|
||||
|
||||
foreach ($version->members as $member) {
|
||||
$members[] = [
|
||||
'target' => $member->content_element_version_id
|
||||
? 'element:'.$member->content_element_version_id
|
||||
: 'composition:'.$member->nested_composition_version_id,
|
||||
];
|
||||
}
|
||||
|
||||
return $this->suggestPicture($members);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param list<array<string, mixed>> $members
|
||||
* @param list<int> $seen
|
||||
* @return array{kind: string, subject: int, alt: string, note: string}|null
|
||||
*/
|
||||
private function suggestPicture(array $members, array $seen = []): ?array
|
||||
{
|
||||
foreach ($members as $member) {
|
||||
$target = (string) ($member['target'] ?? '');
|
||||
|
||||
if (preg_match('/^element:(\d+)$/', $target, $match) === 1) {
|
||||
$version = ContentElementVersion::query()->with('element')->find((int) $match[1]);
|
||||
$element = $version?->element;
|
||||
|
||||
if (! $element instanceof ContentElement || $this->cardUrl('element', $element->id, $element->thumbnail_path) === null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$title = filled($element->display_title) ? $element->display_title : $element->working_title;
|
||||
|
||||
return [
|
||||
'kind' => 'element',
|
||||
'subject' => $element->id,
|
||||
'alt' => filled($element->thumbnail_alt) ? (string) $element->thumbnail_alt : $title,
|
||||
'note' => $element->output_class === 'film'
|
||||
? 'Vorschlag aus dem Film '.$title
|
||||
: 'Vorschlag aus '.$title,
|
||||
];
|
||||
}
|
||||
|
||||
if (preg_match('/^composition:(\d+)$/', $target, $match) !== 1 || in_array((int) $match[1], $seen, true)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$version = CompositionVersion::query()->with('composition', 'members')->find((int) $match[1]);
|
||||
|
||||
if (! $version instanceof CompositionVersion) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$nested = $version->composition;
|
||||
|
||||
if ($this->cardUrl('komposition', $nested->id, $nested->thumbnail_path) !== null) {
|
||||
return [
|
||||
'kind' => 'komposition',
|
||||
'subject' => $nested->id,
|
||||
'alt' => filled($nested->thumbnail_alt) ? (string) $nested->thumbnail_alt : $this->compositionTitle($nested),
|
||||
'note' => 'Vorschlag aus '.$this->compositionTitle($nested),
|
||||
];
|
||||
}
|
||||
|
||||
$children = [];
|
||||
|
||||
foreach ($version->members as $child) {
|
||||
$children[] = [
|
||||
'target' => $child->content_element_version_id
|
||||
? 'element:'.$child->content_element_version_id
|
||||
: 'composition:'.$child->nested_composition_version_id,
|
||||
];
|
||||
}
|
||||
|
||||
$picture = $this->suggestPicture($children, [...$seen, $version->id]);
|
||||
|
||||
if ($picture !== null) {
|
||||
return $picture;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function create(string $designation, CompositionKind $kind): Composition
|
||||
|
||||
Reference in new issue
Block a user