Wähle das Vorschaubild auch aus der Website-Datei eines Films ohne Fassung
CI Feature / test (push) Successful in 1m57s
Deploy Test / test (push) Successful in 1m53s
Deploy Test / deploy (push) Successful in 30s

Die Filmstelle konnte nur aus der Datei einer Inhaltsfassung gezogen werden; ein Medium
mit reiner Website-Datei hatte keine Quelle. Jetzt zieht die Auswahl die Stelle aus der
Website-Datei (Herkunft frame:0@Sekunde, bestehende Leser bleiben gültig). Die Vorschau
des Einzelbilds liegt hinter einer Redaktions-Route.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
LarsandClaude Sonnet 5.5 committed 2026-11-22 07:07:32 +01:00
1 parent be932c113a
commit 5e28538551
7 files changed
+142 -6

No files matched your search

+41 -1
View File
@@ -87,6 +87,27 @@ public function forElementFrame(ContentElement $element, ContentElementVersion $
$this->rememberElement($element, 'frame:'.$version->id.'@'.$this->secondText($seconds));
}
/**
* Vorschaubild aus einer Stelle der Website-Datei. Die Herkunft steht als `frame:0@{Sekunde}`; die 0 steht für die
* Website-Datei (es gibt keine Fassung), alle Leser der Herkunft kommen damit zurecht.
*/
public function forElementWebsiteFrame(ContentElement $element, float $seconds): void
{
$bytes = $this->jpegAtWebsiteFile($element, $seconds);
if (! is_string($bytes)) {
$this->fail($element, 'Aus dieser Filmstelle ließ sich kein Vorschaubild erzeugen.');
return;
}
$name = 'element-'.$element->id;
$path = 'vorschau/'.$name.'.jpg';
Storage::disk('media_derived')->put($path, $bytes);
$this->still($element, Storage::disk('media_derived'), $path, $name);
$this->rememberElement($element, 'frame:0@'.$this->secondText($seconds));
}
public function forCompositionUpload(Composition $composition, string $incoming): void
{
if (! str_starts_with($incoming, 'vorschau/') || str_contains($incoming, '..')) {
@@ -187,7 +208,26 @@ public function frameJpeg(ContentElementVersion $version, float $seconds, int $w
$file = $this->frameInput($version, $original);
if ($file === null) {
return $file === null ? null : $this->jpegFromFile($file, $seconds, $width);
}
/**
* Einzelbild aus der Website-Datei eines Films (`teaser/`), für Medien ohne Inhaltsfassung.
*/
public function jpegAtWebsiteFile(ContentElement $element, float $seconds): ?string
{
$file = $element->preview_path;
if ($element->output_class !== 'film' || ! $this->readableDerived($file, 'teaser/')) {
return null;
}
return $this->jpegFromFile($file, $seconds, 640);
}
private function jpegFromFile(string $file, float $seconds, int $width): ?string
{
if ($seconds < 0 || $seconds > 7200) {
return null;
}