- Simplified media handling by removing the check for images only. - Updated grid layout for media items to use a consistent column size. - Enhanced modal functionality to open specific image previews based on item ID. - Improved code readability by renaming variables and streamlining the foreach loop.
87 lines
4.3 KiB
PHP
87 lines
4.3 KiB
PHP
<x-filament-infolists::entry-wrapper :entry="$entry">
|
|
@php
|
|
$media = $getMedia();
|
|
@endphp
|
|
|
|
@if ($media->isEmpty())
|
|
<div class="flex items-center justify-center rounded-xl border border-dashed border-gray-200 bg-white/50 p-4 text-sm text-gray-500 dark:border-white/10 dark:bg-white/5 dark:text-gray-400">
|
|
{{ __('No files uploaded') }}
|
|
</div>
|
|
@else
|
|
<div
|
|
@class([
|
|
'grid gap-4',
|
|
'grid-cols-[repeat(auto-fill,minmax(200px,1fr))]',
|
|
])
|
|
>
|
|
@foreach ($media as $item)
|
|
@if (str_starts_with($item->mime_type, 'image/'))
|
|
<div class="flex flex-col items-center gap-2">
|
|
<img
|
|
src="{{ $entry->getMediaUrl($item, $media->count() > 1 ? 'thumb' : null) }}"
|
|
class="w-full rounded-lg"
|
|
/>
|
|
<button
|
|
type="button"
|
|
class="text-sm font-medium text-primary-600 decoration-2 center underline focus:outline-none dark:text-primary-500"
|
|
@click="$dispatch('open-modal', { id: 'preview-image-{{ $item->id }}' })"
|
|
>
|
|
{{ __('Watch Full') }}
|
|
</button>
|
|
</div>
|
|
|
|
<x-filament::modal id="preview-image-{{ $item->id }}" width="5xl" :close-button="true">
|
|
<x-slot name="heading">
|
|
{{ $getLabel() }}
|
|
</x-slot>
|
|
|
|
<img
|
|
src="{{ $entry->getMediaUrl($item) }}"
|
|
class="w-full h-full object-contain"
|
|
/>
|
|
</x-filament::modal>
|
|
@else
|
|
<div class="flex items-center gap-3 rounded-xl border border-gray-200 bg-white p-2 shadow-sm dark:border-white/10 dark:bg-white/5">
|
|
<div class="flex h-12 w-12 shrink-0 items-center justify-center rounded-lg bg-gray-100 dark:bg-white/10 overflow-hidden">
|
|
<div class="flex h-full w-full items-center justify-center bg-white dark:bg-gray-800">
|
|
<x-filament::icon
|
|
icon="heroicon-o-document"
|
|
class="h-6 w-6 text-gray-500 dark:text-gray-400"
|
|
/>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex-grow overflow-hidden">
|
|
<p class="truncate text-sm font-medium text-gray-950 dark:text-white" title="{{ $item->name }}">
|
|
{{ $item->name }}
|
|
</p>
|
|
<p class="text-xs text-gray-500 dark:text-gray-400">
|
|
{{ $item->human_readable_size }}
|
|
<span class="text-gray-300 dark:text-gray-600 px-1">•</span>
|
|
<span class="uppercase">{{ $item->extension }}</span>
|
|
</p>
|
|
</div>
|
|
|
|
<div class="flex shrink-0 items-center gap-2 pr-2">
|
|
@if ($isPreviewable())
|
|
<a
|
|
href="{{ $entry->getMediaUrl($item) }}"
|
|
target="_blank"
|
|
rel="noopener noreferrer"
|
|
class="flex items-center justify-center h-8 w-8 rounded-full hover:bg-gray-50 dark:hover:bg-white/10 text-gray-500 hover:text-primary-600 dark:text-gray-400 dark:hover:text-primary-500 transition-colors"
|
|
title="{{ __('View') }}"
|
|
>
|
|
<x-filament::icon
|
|
icon="heroicon-m-eye"
|
|
class="h-5 w-5"
|
|
/>
|
|
</a>
|
|
@endif
|
|
</div>
|
|
</div>
|
|
@endif
|
|
@endforeach
|
|
</div>
|
|
@endif
|
|
</x-filament-infolists::entry-wrapper>
|