Wähle eine Stelle auch aus der Website-Datei eines Films ohne Fassung als Kartenbild
CI Feature / test (push) Successful in 1m57s
Deploy Test / test (push) Successful in 1m57s
Deploy Test / deploy (push) Successful in 26s

Der Regler „Bild aus dem Film“ der Medienkarte blieb bei einem Film nur mit Website-Datei
(zum Beispiel ein Teaser) aus, weil er eine bereitgestellte Fassung verlangte. Die Stelle
kommt jetzt aus der Website-Datei (Herkunft frame:0@Sekunde, wie im Medienmanager), mit
Vorschau über die Redaktionsroute und Übernahme als Bild-Medium in bis zu 1600 px Breite.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-22 08:41:36 +01:00
1 parent 631502c064
commit 1413e0640f
6 files changed
+247 -18

No files matched your search

@@ -107,20 +107,31 @@ protected function imageSourceFields(): array
->view('filament.cms.filmbild-feld')
->dehydrated(false)
->visible(fn (Get $get): bool => $this->filmFor($get('element')) !== null)
->viewData(function (Get $get): array {
$film = $this->filmFor($get('element'));
$stills = app(FilmStill::class);
$version = $film instanceof ContentElement ? $stills->version($film) : null;
->viewData(fn (Get $get): array => $this->filmFieldData($this->filmFor($get('element')))),
];
}
return [
'film' => $film,
'filmTitle' => $film instanceof ContentElement ? (string) ($film->display_title ?: $film->working_title) : '',
'filmVersionId' => $version?->id,
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
];
}),
/**
* Anzeigedaten des Felds „Bild aus dem Film“. Die Stelle kommt aus der bereitgestellten Fassung, bei einem Film
* nur mit Website-Datei aus dieser (Route content.website-frame).
*
* @return array<string, mixed>
*/
protected function filmFieldData(?ContentElement $film): array
{
$stills = app(FilmStill::class);
$version = $film instanceof ContentElement ? $stills->version($film) : null;
return [
'film' => $film,
'filmTitle' => $film instanceof ContentElement ? (string) ($film->display_title ?: $film->working_title) : '',
'filmVersionId' => $version?->id,
'filmWebsiteFrameUrl' => $film instanceof ContentElement && $version === null && $stills->websiteFile($film) !== null
? route('content.website-frame', ['element' => $film])
: null,
'filmHasThumbnail' => $film instanceof ContentElement && is_string($film->thumbnail_path) && $film->thumbnail_path !== '',
'filmThumbnailUrl' => $film instanceof ContentElement ? ThumbnailRef::url('editorial.card', 'element', (int) $film->id, $film->thumbnail_path) : null,
'filmStartSecond' => $film instanceof ContentElement ? ($stills->thumbnailSecond($film) ?? '0') : '0',
];
}
+45 -1
View File
@@ -15,6 +15,8 @@
/**
* Legt ein Bild aus einem Film als gewöhnliches Bild-Medium im Medienmanager ab (Medien- und Materialkarte).
*
* - Die Stelle kommt aus der bereitgestellten Fassung, bei einem Film ohne solche Fassung (zum Beispiel ein Teaser nur
* mit Website-Datei) aus der Website-Datei (`teaser/`, Herkunft `frame:0@Sekunde`).
* - Zwei Wege: das Vorschaubild des Films übernehmen oder eine Stelle (Sekunde) wählen. Beides ist eine
* ausdrückliche Handlung der Redaktion; erst dadurch entsteht ein Bild, das für die Website freigegeben werden kann.
* - Das Bild wird einmal gezogen und gespeichert (WebsiteIntake legt es an, die Warteschlange leitet es ab und gibt
@@ -65,6 +67,23 @@ public function version(ContentElement $film): ?ContentElementVersion
->first();
}
/**
* Die Website-Datei, aus der Stellen gezogen werden, wenn es keine bereitgestellte Fassung gibt (Film nur mit
* Website-Datei). Sonst null.
*/
public function websiteFile(ContentElement $film): ?string
{
$path = $film->preview_path;
if ($this->version($film) instanceof ContentElementVersion
|| ! is_string($path) || $path === '' || str_contains($path, '..') || ! str_starts_with($path, 'teaser/')
|| ! Storage::disk('media_derived')->exists($path)) {
return null;
}
return $path;
}
/** Sekunde der Stelle, aus der das aktuelle Vorschaubild des Films stammt, sonst null. */
public function thumbnailSecond(ContentElement $film): ?string
{
@@ -85,7 +104,11 @@ public function fromSecond(ContentElement $film, float $seconds, ?User $actor =
$version = $this->version($film);
if (! $version instanceof ContentElementVersion) {
throw new DomainRuleException('Der Film hat noch keine bereitgestellte Fassung.');
if ($this->websiteFile($film) !== null) {
return $this->fromWebsiteFrame($film, $seconds, $actor);
}
throw new DomainRuleException('Der Film hat weder eine bereitgestellte Fassung noch eine Website-Datei.');
}
return $this->fromFrame($film, $version, $seconds, $actor);
@@ -158,6 +181,27 @@ private function fromFrame(ContentElement $film, ContentElementVersion $version,
return $this->store($film, $key, $bytes, 'Fassung '.$version->number.', '.str_replace('.', ',', $second).' s', $actor);
}
private function fromWebsiteFrame(ContentElement $film, float $seconds, ?User $actor): ContentElement
{
$second = $this->secondText($seconds);
$key = 'frame:0@'.$second;
$existing = $this->existing($film, $key);
if ($existing instanceof ContentElement) {
$this->reused = true;
return $existing;
}
$bytes = $this->deriver->websiteFileJpeg($film, (float) $second, self::WIDTH);
if (! is_string($bytes)) {
throw new DomainRuleException('Aus dieser Stelle der Website-Datei ließ sich kein Bild erzeugen.');
}
return $this->store($film, $key, $bytes, 'Website-Datei, '.str_replace('.', ',', $second).' s', $actor);
}
private function guard(ContentElement $film): void
{
$refusal = $this->refusal($film);
+10 -1
View File
@@ -215,6 +215,15 @@ public function frameJpeg(ContentElementVersion $version, float $seconds, int $w
* Einzelbild aus der Website-Datei eines Films (`teaser/`), für Medien ohne Inhaltsfassung.
*/
public function jpegAtWebsiteFile(ContentElement $element, float $seconds): ?string
{
return $this->websiteFileJpeg($element, $seconds, 640);
}
/**
* Einzelbild aus der Website-Datei in der gewünschten Breite, nie über die Breite der Datei hinaus (Standbild für
* die Medienkarte, FilmStill).
*/
public function websiteFileJpeg(ContentElement $element, float $seconds, int $width): ?string
{
$file = $element->preview_path;
@@ -222,7 +231,7 @@ public function jpegAtWebsiteFile(ContentElement $element, float $seconds): ?str
return null;
}
return $this->jpegFromFile($file, $seconds, 640);
return $this->jpegFromFile($file, $seconds, $width);
}
private function jpegFromFile(string $file, float $seconds, int $width): ?string