added updating thumbnails

This commit is contained in:
2024-05-01 18:39:33 +10:00
parent bbffddf9ae
commit 1219c9a02e
3 changed files with 36 additions and 1 deletions

View File

@@ -26,7 +26,7 @@
@foreach ($media as $medium)
<tr>
<td class="flex items-center">
<img src="{{ $medium->thumbnail }}" class="max-h-12 max-w-12 -ml-2 -my-3 mr-3 inline rounded" alt="{{ $medium->title }}" />
<img src="{{ $medium->thumbnail }}" class="max-h-12 max-w-12 -ml-2 -my-3 mr-3 inline rounded" alt="{{ $medium->title }}" {{ $medium->status === 'processing' ? 'data-thumbnail=' . $medium->name : '' }} />
<div>
<div class="whitespace-normal">{{ $medium->title }}{!! $medium->password !== null ? '<i class="fa-solid fa-lock text-xs text-gray-400 ml-0.5 -translate-y-1.5 scale-75"></i>': '' !!}</div>
<div class="md:hidden text-xs text-gray-500">{{ $medium->file_type }}</div>

View File

@@ -36,6 +36,10 @@
document.getElementById('{{ $name }}_name').innerText = media.name;
document.getElementById('{{ $name }}_size').innerText = SM.bytesToString(media.size);
if(Object.keys(media).includes('status') && media.status === 'processing') {
SM.updateThumbnail(document.getElementById('{{ $name }}_preview'), media.name);
}
if(!media.mime_type.startsWith('image/') && (!media.thumbnail || media.thumbnail.startsWith('data:'))) {
const extension = media.name.split('.').pop();
document.getElementById('{{ $name }}_preview').src = '/thumbnails/' + extension + '.webp';