31 lines
1.3 KiB
PHP
31 lines
1.3 KiB
PHP
@php
|
|
$type = strpos(parse_url($video_link, PHP_URL_HOST), 'vimeo.com') !== false ? 'vimeo' : null;
|
|
$type = is_null($type) && strpos(parse_url($video_link, PHP_URL_HOST), 'youtube.com') !== false ? 'youtube' : $type;
|
|
$type = is_null($type) && strpos(parse_url($video_link, PHP_URL_HOST), 'youtu.be') !== false ? 'youtube' : $type;
|
|
$video_id = \App\Lib\Utils::getVideoId(strval($video_link));
|
|
$video_url = null;
|
|
switch ($type) {
|
|
case 'youtube':
|
|
$video_url = "https://www.youtube.com/embed/{$video_id}";
|
|
break;
|
|
case 'vimeo':
|
|
$video_url = "https://player.vimeo.com/video/{$video_id}";
|
|
break;
|
|
default:
|
|
$video_url = $video_link;
|
|
}
|
|
@endphp
|
|
@if (in_array($type, ['youtube', 'vimeo']))
|
|
<div type="{{ $type }}" href="{{ $video_url }}" @class(array_merge($wrapper_class ?? [], ['video-inlaid']))
|
|
@if (!empty($wrapper_id)) id="{{ $wrapper_id }}" @endif>
|
|
@include('front.partials.inline-cookie', [
|
|
'cookie_name' => $type,
|
|
'class' => ['d-flex-column'],
|
|
'text_line_1' => __('You must accept cookies :type to view the videos.', [
|
|
'type' => $type,
|
|
]),
|
|
])
|
|
</div>
|
|
@else
|
|
<video src="{{ $video_link }}" controls></video>
|
|
@endif
|