Skip to content

Commit bb034a5

Browse files
committed
open images, files in browser in media-picker
1 parent 9e7180f commit bb034a5

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/media/resources/views/forms/components/media-picker.blade.php

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,12 @@
119119
@if ($this instanceof \Filament\Resources\Pages\EditRecord || $this instanceof \Filament\Resources\Pages\CreateRecord)
120120
<x-filament::button color="primary" size="sm" class="w-full flex items-center justify-center space-x-2"
121121
x-on:click="
122-
$dispatch('set-media-picker-model', {
123-
modelId: {{ $getRecord()?->id ?? 0 }},
124-
modelClass: '{{ $getRecord() ? addslashes($getRecord()::class) : addslashes($this->getResource()::getModel()) }}'
125-
});
126-
$dispatch('open-modal', { id: 'mediaPickerModal' });
127-
">
122+
$dispatch('set-media-picker-model', {
123+
modelId: {{ $getRecord()?->id ?? 0 }},
124+
modelClass: '{{ $getRecord() ? addslashes($getRecord()::class) : addslashes($this->getResource()::getModel()) }}'
125+
});
126+
$dispatch('open-modal', { id: 'mediaPickerModal' });
127+
">
128128
<span>{{ __('media::fields.select_media') }}</span>
129129
</x-filament::button>
130130
@endif
@@ -141,11 +141,13 @@ class="relative group bg-white rounded-lg shadow hover:shadow-md transition-shad
141141
<div>
142142
<template x-if="media.mime_type && media.mime_type.startsWith('image/')">
143143
<img :src="media . url" :alt="media . name"
144-
class="w-full h-32 object-cover rounded-t-lg" />
144+
class="w-full h-32 object-cover rounded-t-lg cursor-pointer"
145+
x-on:click="window.open(media.url, '_blank')" />
145146
</template>
146147

147148
<template x-if="media.mime_type && !media.mime_type.startsWith('image/')">
148-
<div class="flex flex-col justify-between items-center w-full h-32 mt-3">
149+
<div class="flex flex-col justify-between items-center w-full h-32 mt-3 cursor-pointer"
150+
x-on:click="window.open(media.url, '_blank')">
149151
<img :src="$el . dataset . baseUrl + getIconForMimeType(media . mime_type)"
150152
data-base-url="{{ asset('') }}" class="w-16 h-16" />
151153
<div class="text-xs text-gray-700 w-full mt-2 overflow-hidden text-ellipsis whitespace-normal break-words px-2"

0 commit comments

Comments
 (0)