@forelse ($galleries as $gallery)
@empty
Nenhuma galeria disponível.
@endforelse
@endif
@if ($section === 'videos')
@foreach ($videos as $video)
@if (strpos($video->url, 'youtube.com') !== false || strpos($video->url, 'youtu.be') !== false)
@php
// Extrair o ID do vídeo da URL
preg_match(
'/(?:youtube\.com\/(?:[^\/]+\/[^\/]+\/|(?:v|e(?:mbed)?)\/|\S*?[?&]v=)|youtu\.be\/)([a-zA-Z0-9_-]{11})/',
$video->url,
$matches,
);
$video_id = $matches[1] ?? null;
@endphp
@if ($video_id)
@else
⚠️ Vídeo não encontrado.
@endif
@else
@endif
@endforeach
@foreach ($podcasts as $video)
@php
$video_id = null;
$parts = parse_url($video->url);
if (!empty($parts['host']) && str_contains($parts['host'], 'youtu.be')) {
$video_id = ltrim($parts['path'], '/');
} elseif (!empty($parts['query'])) {
parse_str($parts['query'], $query);
$video_id = $query['v'] ?? null;
} elseif (
!empty($parts['path']) &&
preg_match('/\/embed\/([a-zA-Z0-9_-]{11})/', $parts['path'], $m)
) {
$video_id = $m[1];
} elseif (
!empty($parts['path']) &&
preg_match('/\/live\/([a-zA-Z0-9_-]{11})/', $parts['path'], $m)
) {
$video_id = $m[1];
}
@endphp
@if ($video_id)
@else
⚠️ Este vídeo não pode ser incorporado.
Abrir no YouTube
@endif
@endforeach