From 4c0917e6ba4128f2ef90e6d805f2548183960f31 Mon Sep 17 00:00:00 2001 From: Nurmuhammet Allanov Date: Tue, 9 Dec 2025 01:40:07 +0500 Subject: [PATCH] Refactor media display logic in SpatieMediaLibraryFileEntry component - 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. --- .../spatie-media-library-file-entry.blade.php | 125 ++++++++---------- 1 file changed, 57 insertions(+), 68 deletions(-) diff --git a/resources/views/filament/infolists/components/spatie-media-library-file-entry.blade.php b/resources/views/filament/infolists/components/spatie-media-library-file-entry.blade.php index be55c06..25b75a9 100644 --- a/resources/views/filament/infolists/components/spatie-media-library-file-entry.blade.php +++ b/resources/views/filament/infolists/components/spatie-media-library-file-entry.blade.php @@ -1,96 +1,85 @@ @php $media = $getMedia(); - $hasImagesOnly = $media->every(fn($m) => str_starts_with($m->mime_type, 'image/')); @endphp @if ($media->isEmpty())
{{ __('No files uploaded') }}
- @elseif ($hasImagesOnly) + @else
$media->count() > 1, + 'grid-cols-[repeat(auto-fill,minmax(200px,1fr))]', ]) > - @foreach ($media as $medium) -
- - -
+ @foreach ($media as $item) + @if (str_starts_with($item->mime_type, 'image/')) +
+ + +
- - - {{ $getLabel() }} - + + + {{ $getLabel() }} + - - - @endforeach -
- @else -
- @foreach ($getMedia() as $media) -
-
- @if (str_starts_with($media->mime_type, 'image/')) - {{ $media->name }} - @else + + + @else +
+
- @endif -
+
-
-

- {{ $media->name }} -

-

- {{ $media->human_readable_size }} - - {{ $media->extension }} -

-
+
+

+ {{ $item->name }} +

+

+ {{ $item->human_readable_size }} + + {{ $item->extension }} +

+
-
- @if ($isPreviewable()) - - - - @endif +
+ @if ($isPreviewable()) + + + + @endif +
-
+ @endif @endforeach
@endif