Skip to content

Commit

Permalink
thumbs
Browse files Browse the repository at this point in the history
  • Loading branch information
bastihilger committed Feb 22, 2022
1 parent af11aad commit 77aa5c5
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 9 deletions.
2 changes: 2 additions & 0 deletions config/nova-cms-portfolio.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
'custom_work_label' => '',
'artists_have_custom_bg' => true,
'artists_are_sortable' => false,
'has_quick_upload' => true,
'max_thumbnails' => 3,
'media' => [
'only_upload' => true,
],
Expand Down
20 changes: 12 additions & 8 deletions src/Nova/Slideshow.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,12 +112,12 @@ public function fields(Request $request)
->onlyOnForms(),

Stack::make($workLabel, [
Line::make('', function () {
Text::make('', function () {
$html = '<a
href="/nova/resources/slideshows/'.$this->id.'"
class=""
class="block whitespace-normal"
>';
foreach ($this->works->take(3) as $work) {
foreach ($this->works->take(config('nova-cms-portfolio.max_thumbnails') ?: 3) as $work) {
if (nova_cms_mime($work->file) == 'video') {
$html .= '<video
autoplay muted loop playsinline
Expand Down Expand Up @@ -226,11 +226,15 @@ class="btn btn-xs

public function cards(Request $request)
{
return [
(new QuickWorksCard)->addMeta($request->resourceId)->onlyOnDetail(),
(new SlideshowArtistCard)->addMeta($request->resourceId)->onlyOnDetail(),
// (new EditSlideshowCard)->addMeta($request->resourceId)->onlyOnDetail(),
];
$cards = [];

if (config('nova-cms-portfolio.has_quick_upload')) {
$cards[] = (new SlideshowArtistCard)->addMeta($request->resourceId)->onlyOnDetail();
}

$cards[] = (new SlideshowArtistCard)->addMeta($request->resourceId)->onlyOnDetail();

return $cards;
}

public function actions(Request $request)
Expand Down
23 changes: 22 additions & 1 deletion src/Nova/Work.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,28 @@ public function fields(Request $request)

return [
MediaLibrary::make(__('nova-cms::content_blocks.file'), 'file')
->uploadOnly($uploadOnly),
->uploadOnly($uploadOnly)
->onlyOnForms(),

Line::make('', function () {
$html = '';

if (nova_cms_mime($this->file) == 'video') {
$html .= '<video
autoplay muted loop playsinline
class="w-auto h-12 mr-1 inline-block"
>
<source src="'.nova_cms_file($this->file).'" type="video/'.nova_cms_extension($this->file).'">
</video>';
} else {
$html .= '<img
class="w-auto h-12 mr-1 inline-block"
src="'.nova_cms_image($this->file, 'thumb').'"
/>';
}

return $html;
})->asHtml(),

Stack::make('Details', [
Line::make('', function () {
Expand Down

0 comments on commit 77aa5c5

Please sign in to comment.