Fix embeds to include note content where both exists

This commit is contained in:
Ben Goldsworthy 2022-12-14 22:05:35 +00:00
parent b586687174
commit 802c9398d5
3 changed files with 46 additions and 35 deletions

View file

@ -91,29 +91,25 @@
}).addTo(map);
@php $popupContent = null; @endphp
@if(preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath))
@if(preg_match("/\.webm/", $filepath[1]))
@php
$popupContent = '<video class="popup__video" controls><source src="/videos/';
$popupContent .= $filepath[1];
$popupContent .= '" type="video/webm">';
$popupContent .= '<p>Your browser doesn\'t support HTML video. Here is a <a href="/';
$popupContent .= $filepath[1];
$popupContent .= '">link to the video</a> instead.</p></video>';
@endphp
@elseif(preg_match("/\.ogg/", $filepath[1]))
@php
$popupContent = '<audio class="popup__audio" controls><source src="/audio/';
$popupContent .= $filepath[1];
$popupContent .= '" type="audio/ogg">';
$popupContent .= '<p>Download <a href="/';
$popupContent .= $filepath[1];
$popupContent .= '">OGG</a> audio.</p></audio>';
@endphp
@endif
@else
@php
$embed = null;
if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) {
if (preg_match("/\.webm/", $filepath[1])) {
$embed = '<video class="popup__video" controls>';
$embed .= '<source src="' . url("/videos/" . $filepath[1]) . '" type="video/webm">';
$embed .= '<p>Your browser doesn\'t support HTML video. Here is a <a href="' . url("/videos/" . $filepath[1]) . '">link to the video</a> instead.</p>';
$embed .= '</video>';
} elseif (preg_match("/\.ogg/", $filepath[1])) {
$embed = '<audio class="popup__audio" controls>';
$embed .= '<source src="' . url("/audio/" . $filepath[1]) . '" type="audio/ogg">';
$embed .= '<p>Download <a href="' . url("/audio/" . $filepath[1]) . '">OGG</a> audio.</p>';
$embed .= '</audio>';
}
$checkin->note = preg_replace("/\[\[[^\]]+\]\]/", $embed, $checkin->note);
}
@endphp
@php $popupContent ='<p class="popup__note">' . $checkin->note . '</p>'; @endphp
@endif
popupMarkup = `<h2 class="popup__title">{!! $checkin->title ?? "<i>Untitled</i>" !!}</h2>`;
popupMarkup += `{!! $popupContent !!}`;