Wähle eine Stelle auch aus der Website-Datei eines Films ohne Fassung als Kartenbild
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:
1 parent
631502c064
commit
1413e0640f
6 files changed
+247
-18
No files matched your search
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in new issue
Block a user