Files

27 lines
1.2 KiB
PHP
Raw Permalink Normal View History

@php
$assetStorage = app(\App\Support\AssetStorage\AssetStorage::class);
$url = $assetStorage->url($asset);
$isText = $asset->type === 'script' || in_array($asset->mime_type, ['application/json', 'text/plain']);
@endphp
<div>
@if ($asset->type === 'image')
<img src="{{ $url }}" alt="" class="max-w-full max-h-64 rounded border border-gray-200">
@elseif ($asset->type === 'audio')
<audio controls preload="none" src="{{ $url }}" class="w-full"></audio>
@elseif ($asset->type === 'video')
<video controls preload="none" src="{{ $url }}" class="max-w-full max-h-64 rounded border border-gray-200"></video>
@elseif ($isText)
<pre class="bg-gray-50 border border-gray-200 rounded p-3 text-xs max-h-48 overflow-y-auto whitespace-pre-wrap">{{ \Illuminate\Support\Str::limit($assetStorage->contents($asset), 1000) }}</pre>
@else
<a href="{{ $url }}" target="_blank" class="text-blue-600 text-sm">Download {{ $asset->type }}</a>
@endif
<div class="text-xs text-gray-500 mt-1">
{{ ucfirst($asset->type) }} &middot; v{{ $asset->version }}
@if ($asset->size_bytes)
&middot; {{ number_format($asset->size_bytes / 1024, 1) }} KB
@endif
</div>
</div>