{{-- @intent Exibição universal e acessível de mídias (Imagem, PDF, Áudio, Planilha) na V2. @description Utiliza semântica HTML5 (figure/figcaption) e padrões WCAG AAA. Detecta automaticamente o tipo pela extensão do path se 'type' não for informado. @param string $path Caminho original do arquivo. @param array $variants Variantes responsivas (kit WebP). @param string $type Tipo da mídia (image|pdf|audio|spreadsheet). Se omitido, detecta pela extensão. @param string $disk Disco de armazenamento (default: public). @param string $alt Texto alternativo (Obrigatório para Acessibilidade). @param string $narrationText Texto da narração (opcional — exibido como accordion no áudio). --}} @php $disk = $disk ?? 'public'; $alt = $alt ?? ''; $narrationText = $narrationText ?? ''; $variants = isset($variants) && is_array($variants) ? $variants : []; /* Detecta tipo automaticamente pela extensão se não informado */ if (!isset($type) || empty($type)) { $ext = strtolower(pathinfo($path, PATHINFO_EXTENSION)); $audioExts = ['mp3', 'wav', 'ogg', 'm4a', 'aac', 'webm', 'wma']; $spreadsheetExts = ['xlsx', 'xls', 'csv', 'ods']; $pdfExts = ['pdf']; if (in_array($ext, $pdfExts)) { $type = 'pdf'; } elseif (in_array($ext, $audioExts)) { $type = 'audio'; } elseif (in_array($ext, $spreadsheetExts)) { $type = 'spreadsheet'; } else { $type = 'image'; } } $fileUrl = v2_storage_url($path); $filename = basename($path); $showActions = !isset($noActions) || !$noActions; @endphp
{{-- ==================== IMAGEM ==================== --}} @if($type === 'image')
@include('v2-service-media::components.picture', [ 'originalPath' => $path, 'variants' => $variants, 'disk' => $disk, 'alt' => $alt ?: 'Imagem: ' . $filename, 'class' => 'img-fluid mx-auto d-block transition-all hover-zoom', 'style' => 'max-height: 400px;' ])
{{-- ==================== PDF ==================== --}} @elseif($type === 'pdf') @if(!empty($variants)) {{-- PDF com capa gerada --}}
@include('v2-service-media::components.picture', [ 'originalPath' => $path, 'variants' => $variants, 'disk' => $disk, 'alt' => $alt ?: 'Capa do PDF: ' . $filename, 'class' => 'img-fluid mx-auto d-block transition-all hover-zoom', 'style' => 'max-height: 400px;' ])
@else {{-- PDF sem capa -- visual customizado --}}
Documento PDF

{{ $filename }}

@endif {{-- ==================== ÁUDIO ==================== --}} @elseif($type === 'audio')
{{-- Cabeçalho do áudio --}}
{{ $alt ?: $filename }}
Arquivo de áudio
{{-- Player nativo --}} {{-- Ondas decorativas animadas --}}
@if(!empty($narrationText))
@endif
{{-- ==================== PLANILHA ==================== --}} @elseif($type === 'spreadsheet')
{{-- Cabeçalho da planilha --}}
{{ $alt ?: $filename }}
Planilha / Tabela de dados
{{-- Mini tabela decorativa --}}
# Dado A Dado B Dado C
1 Lorem Ipsum Dolor
2 Sit Amet Consectetur
3 Adipiscing Elit Sed do
{{-- ==================== FALLBACK GENÉRICO ==================== --}} @else
Documento

{{ $filename }}

@endif {{-- ==================== AÇÕES E METADADOS ==================== --}} @if($showActions)
@if($type === 'pdf') Visualizar PDF (Nova Aba) @elseif($type === 'image') Ver Original (Full HD) @elseif($type === 'audio') Abrir Player (Nova Aba) @elseif($type === 'spreadsheet') Abrir Planilha (Original) @endif @if($type !== 'audio') Fazer Download @endif
@if(!empty($alt))
Descrição da mídia:

{{ $alt }}

@endif
@endif
@push('head-styles') @endpush @push('scripts') @endpush