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

+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);