Zeige Katalogkarten, Titelbilder und klare Freigabestatus im Arbeitsplatz.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
053a361801
commit
9195cdcd15
15 files changed
+795
-59
No files matched your search
@@ -12,8 +12,10 @@ class Composition extends Model
|
||||
'designation',
|
||||
'display_title',
|
||||
'summary',
|
||||
'description',
|
||||
'thumbnail_path',
|
||||
'thumbnail_alt',
|
||||
'thumbnail_source',
|
||||
'thumbnail_error',
|
||||
'public_slug',
|
||||
'kind',
|
||||
|
||||
@@ -41,6 +41,21 @@ public function forCompositionUpload(Composition $composition, string $incoming)
|
||||
}
|
||||
|
||||
$this->still($composition, Storage::disk('cms_incoming'), $incoming, 'komposition-'.$composition->id);
|
||||
$this->rememberChoice($composition, 'eigen');
|
||||
}
|
||||
|
||||
public function forCompositionFromElement(Composition $composition, ContentElement $element): void
|
||||
{
|
||||
$path = $element->thumbnail_path;
|
||||
|
||||
if (! is_string($path) || ! str_starts_with($path, 'vorschau/') || str_contains($path, '..')) {
|
||||
$this->failComposition($composition, 'Für dieses Medium liegt noch kein Vorschaubild vor.');
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
$this->still($composition, Storage::disk('media_derived'), $path, 'komposition-'.$composition->id);
|
||||
$this->rememberChoice($composition, 'element:'.$element->id);
|
||||
}
|
||||
|
||||
private function frame(ContentElement $element, string $file): void
|
||||
@@ -119,11 +134,27 @@ private function still(ContentElement|Composition $subject, Filesystem $disk, st
|
||||
$path = 'vorschau/'.$name.'.jpg';
|
||||
Storage::disk('media_derived')->put($path, $bytes);
|
||||
$subject->thumbnail_path = $path;
|
||||
$subject->thumbnail_alt = $subject instanceof Composition ? $subject->designation : $subject->working_title;
|
||||
|
||||
if (! ($subject instanceof Composition && filled($subject->thumbnail_alt))) {
|
||||
$subject->thumbnail_alt = $subject instanceof Composition ? $subject->designation : $subject->working_title;
|
||||
}
|
||||
|
||||
$subject->thumbnail_error = null;
|
||||
$subject->save();
|
||||
}
|
||||
|
||||
private function rememberChoice(Composition $composition, string $source): void
|
||||
{
|
||||
$composition->refresh();
|
||||
|
||||
if ($composition->thumbnail_error !== null || ! filled($composition->thumbnail_path)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$composition->thumbnail_source = $source;
|
||||
$composition->save();
|
||||
}
|
||||
|
||||
private function fail(ContentElement $element, string $reason): void
|
||||
{
|
||||
$this->failSubject($element, $reason);
|
||||
|
||||
Reference in new issue
Block a user