don't preload videos

This commit is contained in:
Ben Goldsworthy 2024-08-27 16:57:33 +02:00
parent 12bfb800ce
commit 5748f5c2f2
Signed by: Rumperuu
SSH key fingerprint: SHA256:e5XfzNOr9UvWpEzyLfw0GtTMZWIFh3NmxH+/qQIi3xE
3 changed files with 12 additions and 12 deletions

View file

@ -285,7 +285,7 @@ body {
max-height: 45vh; max-height: 45vh;
margin-top: 1em; margin-top: 1em;
display: block; display: block;
background-color: white; background-color: black;
border: 2px solid var(--dark, #020202); border: 2px solid var(--dark, #020202);
} }

View file

@ -6,14 +6,14 @@
if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) { if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) {
if (preg_match("/\.webm/", $filepath[1])) { if (preg_match("/\.webm/", $filepath[1])) {
$hasEmbed = 'videos'; $hasEmbed = 'videos';
$trip_slug = preg_replace( '/[^A-Za-z0-9-]+/', '-', strtolower( $trip->name ) ); $trip_slug = preg_replace( '/[^A-Za-z0-9-]+/', '-', strtolower( $trip->name ) );
if (file_exists(public_path() . "/" . $trip_slug . "/" . $hasEmbed . "/" . $filepath[1])) { if (file_exists(public_path() . "/" . $trip_slug . "/" . $hasEmbed . "/" . $filepath[1])) {
$path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1]; $path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1];
$embed = '<video class="popup__video" controls>'; $embed = '<video class="popup__video" preload="none" controls>';
$embed .= '<source src="' . secure_url( $path ) . '" type="video/webm">'; $embed .= '<source src="' . secure_url( $path ) . '" type="video/webm">';
$embed .= '<p>Your client doesn\'t support HTML video. Here is a <a href="' . secure_url( $path ) . '">link to the video</a> instead.</p>'; $embed .= '<p>Your client doesn\'t support HTML video. Here is a <a href="' . secure_url( $path ) . '">link to the video</a> instead.</p>';
$embed .= '</video>'; $embed .= '</video>';
if (isset($email)) { if (isset($email)) {
$embed .= '<p><i>If your email client doesn\'t support video embeds, here is a <a href="' . secure_url( $path ) . '">link to the file</a> instead.</i></p>'; $embed .= '<p><i>If your email client doesn\'t support video embeds, here is a <a href="' . secure_url( $path ) . '">link to the file</a> instead.</i></p>';
} }
@ -23,14 +23,14 @@
} }
} elseif (preg_match("/\.ogg/", $filepath[1])) { } elseif (preg_match("/\.ogg/", $filepath[1])) {
$hasEmbed = 'audio'; $hasEmbed = 'audio';
$trip_slug = preg_replace( '/[^A-Za-z0-9-]+/', '-', strtolower( $trip->name ) ); $trip_slug = preg_replace( '/[^A-Za-z0-9-]+/', '-', strtolower( $trip->name ) );
if (file_exists(public_path() . "/" . $trip_slug . "/" . $hasEmbed . "/" . $filepath[1])) { if (file_exists(public_path() . "/" . $trip_slug . "/" . $hasEmbed . "/" . $filepath[1])) {
$path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1]; $path = "/" . $trip_slug . "/" .$hasEmbed . "/" . $filepath[1];
$embed = '<audio class="popup__audio" controls>'; $embed = '<audio class="popup__audio" preload="none" controls>';
$embed .= '<source src="' . secure_url( $path ) . '" type="audio/ogg">'; $embed .= '<source src="' . secure_url( $path ) . '" type="audio/ogg">';
$embed .= '<p>Download <a href="' . secure_url( $path ) . '">OGG</a> audio.</p>'; $embed .= '<p>Download <a href="' . secure_url( $path ) . '">OGG</a> audio.</p>';
$embed .= '</audio>'; $embed .= '</audio>';
if (isset($email)) { if (isset($email)) {
$embed .= '<p><i>If your email client doesn\' support audio embeds, here is a <a href="' . secure_url( $path ) . '">link to the file</a> instead.</i></p>'; $embed .= '<p><i>If your email client doesn\' support audio embeds, here is a <a href="' . secure_url( $path ) . '">link to the file</a> instead.</i></p>';
} }
@ -47,14 +47,14 @@
<h2 class="checkin__title"> <h2 class="checkin__title">
{!! $checkin->title ?? "<i>Untitled</i>" !!} {!! $checkin->title ?? "<i>Untitled</i>" !!}
@if($checkin->image_url) @if($checkin->image_url)
<span class="checkin-icon">🖼️</span> <span class="checkin-icon">🖼️</span>
@endif @endif
@if($hasEmbed) @if($hasEmbed)
@if($hasEmbed === 'videos') @if($hasEmbed === 'videos')
<span class="checkin-icon @if($embedMissing) checkin-icon--missing @endif">&#128249;</span> <span class="checkin-icon @if($embedMissing) checkin-icon--missing @endif">&#128249;</span>
@endif @endif
@if($hasEmbed === 'audio') @if($hasEmbed === 'audio')
<span class="checkin-icon @if($embedMissing) checkin-icon--missing @endif">&#128264;</span> <span class="checkin-icon @if($embedMissing) checkin-icon--missing @endif">&#128264;</span>
@endif @endif
@endif @endif

View file

@ -127,13 +127,13 @@
$embed = null; $embed = null;
if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) { if (preg_match("/\[\[([^\]]+)\]\]/", $checkin->note, $filepath)) {
if (preg_match("/\.webm/", $filepath[1])) { if (preg_match("/\.webm/", $filepath[1])) {
$embed = '<video class="popup__video" controls>'; $embed = '<video class="popup__video" prefetch="none" controls>';
$embed .= '<source src="' . url("/videos/" . $filepath[1]) . '" type="video/webm">'; $embed .= '<source src="' . url("/videos/" . $filepath[1]) . '" type="video/webm">';
$embed .= '<p>Your browser doesn\'t support HTML video. Here is a <a href="'; $embed .= '<p>Your browser doesn\'t support HTML video. Here is a <a href="';
$embed .= url("/videos/" . $filepath[1]) . '">link to the video</a> instead.</p>'; $embed .= url("/videos/" . $filepath[1]) . '">link to the video</a> instead.</p>';
$embed .= '</video>'; $embed .= '</video>';
} elseif (preg_match("/\.ogg/", $filepath[1])) { } elseif (preg_match("/\.ogg/", $filepath[1])) {
$embed = '<audio class="popup__audio" controls>'; $embed = '<audio class="popup__audio" prefetch="none" controls>';
$embed .= '<source src="' . url("/audio/" . $filepath[1]) . '" type="audio/ogg">'; $embed .= '<source src="' . url("/audio/" . $filepath[1]) . '" type="audio/ogg">';
$embed .= '<p>Download <a href="' . url("/audio/" . $filepath[1]) . '">OGG</a> audio.</p>'; $embed .= '<p>Download <a href="' . url("/audio/" . $filepath[1]) . '">OGG</a> audio.</p>';
$embed .= '</audio>'; $embed .= '</audio>';