Add audio and video embeds to map popups

This commit is contained in:
Ben Goldsworthy 2022-11-28 14:54:06 -06:00
parent 6797150c73
commit 0457509482

View file

@ -88,8 +88,25 @@
icon: markerIcon icon: markerIcon
}).addTo(map); }).addTo(map);
$popupContent = null;
@if(preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath))
@if(preg_match("/\.webm/", $filepath[1]))
@php $popupContent = `<video controls>
<source src="/{{ $filepath[1] }}" type="video/webm">
<p>Your browser doesn't support HTML video. Here is a <a href="/{{ $filepath[1] }}">link to the video</a> instead.</p>
</video>`; @endphp
@elseif(preg_match("/\.ogg/", $filepath[1]))
@php $popupContent = `<audio controls>
<source src="/{{ $filepath[1] }}" type="audio/off">
<p>Download <a href="/{{ $filepath[1] }}">OGG</a> audio.</p>
</audio>`; @endphp
@endif
@else
@php $popupContent = `<p class="popup__note">{!! $checkin->note !!}</p>`; @endphp
@endif
popupMarkup = `<h2 class="popup__title">{!! $checkin->title ?? "<i>Untitled</i>" !!}</h2>`; popupMarkup = `<h2 class="popup__title">{!! $checkin->title ?? "<i>Untitled</i>" !!}</h2>`;
popupMarkup += `<p class="popup__note">{!! $checkin->note !!}</p>`; popupMarkup += $popupContent;
popupMarkup += '<img class="popup__image" src="{{ $checkin->image_url }}">'; popupMarkup += '<img class="popup__image" src="{{ $checkin->image_url }}">';
marker.bindPopup(popupMarkup).openPopup(); marker.bindPopup(popupMarkup).openPopup();