@endauth
{{ $form->title }}
{{-- @if ($form->description)
{!! Purifier::clean($form->description) !!}
@endif --}}
@if ($form->image && $form->active_image)
@endif
{{-- @if ($form->video && $form->active_video)
@php
if (!function_exists('vimeo_aspect_ratio')) {
function vimeo_aspect_ratio(string $videoId, ?string $videoHash = null): string
{
$cacheKey = 'vimeo_oembed_ar_' . $videoId . '_' . ($videoHash ?? 'nohash');
return cache()->remember($cacheKey, 86400, function () use (
$videoId,
$videoHash,
) {
try {
$playerUrl =
'https://player.vimeo.com/video/' .
$videoId .
($videoHash ? '?h=' . $videoHash : '');
$oembedUrl =
'https://vimeo.com/api/oembed.json?url=' . urlencode($playerUrl);
$resp = \Illuminate\Support\Facades\Http::timeout(5)
->retry(2, 100)
->get($oembedUrl);
if ($resp->ok()) {
$data = $resp->json();
if (!empty($data['width']) && !empty($data['height'])) {
return $data['height'] > $data['width'] ? '9/16' : '16/9';
}
}
} catch (\Throwable $e) {
// fallback
}
return '16/9';
});
}
}
@endphp
@foreach ($videos as $index => $video)
@php
$videoUrl = $video;
$videoId = null;
$videoHash = null;
$isVimeo = false;
$isInstagram = false;
$isTikTok = false;
$isShorts = false;
$instagramType = null;
$aspectRatio = '16/9';
$maxWidth = '800px';
// -----------------------------
// YOUTUBE
// -----------------------------
if (preg_match('#youtu\.be/([a-zA-Z0-9_-]+)#', $videoUrl, $m)) {
$videoId = $m[1];
} elseif (preg_match('#youtube\.com/watch\?v=([a-zA-Z0-9_-]+)#', $videoUrl, $m)) {
$videoId = $m[1];
} elseif (preg_match('#youtube\.com/shorts/([a-zA-Z0-9_-]{11})#', $videoUrl, $m)) {
$videoId = $m[1];
$isShorts = true;
} elseif (preg_match('#youtu\.be/([a-zA-Z0-9_-]{11})#', $videoUrl, $m)) {
$videoId = $m[1];
}
if ($isShorts) {
$aspectRatio = '9/16';
$maxWidth = '450px';
}
// -----------------------------
// VIMEO (all formats)
// -----------------------------
if (str_contains($videoUrl, 'vimeo.com')) {
$isVimeo = true;
if (preg_match('#vimeo\.com/(?:video/)?(\d+)#', $videoUrl, $m)) {
$videoId = $m[1];
}
if (preg_match('#vimeo\.com/\d+/([a-zA-Z0-9]+)#', $videoUrl, $m)) {
$videoHash = $m[1];
}
parse_str(parse_url($videoUrl, PHP_URL_QUERY) ?? '', $q);
if (!empty($q['h'])) {
$videoHash = $q['h'];
}
// Aspect ratio helper (your existing function)
if ($videoId) {
$aspectRatio = vimeo_aspect_ratio($videoId, $videoHash);
if ($aspectRatio === '9/16') {
$maxWidth = '450px';
}
}
}
// -----------------------------
// INSTAGRAM (reels, posts, IGTV)
// -----------------------------
if (str_contains($videoUrl, 'instagram.com')) {
if (preg_match('#instagram\.com/(reel|p|tv)/([^/?]+)#', $videoUrl, $m)) {
$instagramType = $m[1];
$videoId = $m[2];
$isInstagram = true;
$aspectRatio = '9/16';
$maxWidth = '450px';
}
}
// -----------------------------
// TIKTOK
// -----------------------------
if (str_contains($videoUrl, 'tiktok.com')) {
if (preg_match('#/video/(\d+)#', $videoUrl, $m)) {
$videoId = $m[1];
$isTikTok = true;
$aspectRatio = '9/16';
$maxWidth = '450px';
}
}
@endphp
@if ($isVimeo && $videoId)
@elseif ($isInstagram && $videoId)
@elseif ($isTikTok && $videoId)
@elseif ($videoId)
@endif
@endforeach
@endif --}}
@if ($form->video && $form->active_video)
@php
$videoUrl = $form->video;
$videoId = null;
$videoHash = null;
$isVimeo = false;
$isInstagram = false;
$isTikTok = false;
$isShorts = false;
$aspectRatio = '16/9';
$maxWidth = '800px';
// --- YouTube + Shorts ---
if (preg_match('#youtu\.be/([a-zA-Z0-9_-]+)#', $videoUrl, $m)) {
$videoId = $m[1];
} elseif (preg_match('#youtube\.com/watch\?v=([a-zA-Z0-9_-]+)#', $videoUrl, $m)) {
$videoId = $m[1];
} elseif (preg_match('#youtube\.com/shorts/([a-zA-Z0-9_-]{11})#', $videoUrl, $m)) {
$videoId = $m[1];
$isShorts = true;
}
if ($isShorts) {
$aspectRatio = '9/16';
$maxWidth = '450px';
}
// --- Vimeo ---
if (str_contains($videoUrl, 'vimeo.com')) {
$isVimeo = true;
if (preg_match('#vimeo\.com/(?:video/)?(\d+)#', $videoUrl, $m)) {
$videoId = $m[1];
}
if (preg_match('#vimeo\.com/\d+/([a-zA-Z0-9]+)#', $videoUrl, $m)) {
$videoHash = $m[1];
}
parse_str(parse_url($videoUrl, PHP_URL_QUERY) ?? '', $q);
if (!empty($q['h'])) {
$videoHash = $q['h'];
}
$aspectRatio = '16/9';
}
// --- Instagram ---
if (str_contains($videoUrl, 'instagram.com')) {
if (preg_match('#instagram\.com/(reel|p|tv)/([^/?]+)#', $videoUrl, $m)) {
$isInstagram = true;
$instagramType = $m[1];
$videoId = $m[2];
$aspectRatio = '9/16';
$maxWidth = '450px';
}
}
// --- TikTok ---
if (str_contains($videoUrl, 'tiktok.com') && preg_match('#/video/(\d+)#', $videoUrl, $m)) {
$videoId = $m[1];
$isTikTok = true;
$aspectRatio = '9/16';
$maxWidth = '450px';
}
@endphp
{{-- Vimeo --}}
@if ($isVimeo && $videoId)
{{-- Instagram --}}
@elseif ($isInstagram && $videoId)
{{-- TikTok --}}
@elseif ($isTikTok && $videoId)
{{-- YouTube + Shorts --}}
@elseif ($videoId)
@endif
@endif
@if ($form->description)
{!! Purifier::clean($form->description) !!}
@endif
{{-- form here --}}
{{-- @if ($event->button_link)
@endif --}}