- Fixed the thumbnail loading issue on paginated pretty URLs.

The bug was relative media paths like media/thumbs/... resolving under 
routes such as /v/<slug>?page=2 or /search/<query>?page=2. I added 
public_media_url() in 
[includes/db.php](/Users/tyemeclifford/Documents/GH/mediaplayer/includes/db.php) 
and updated public thumbnails, posters, and local player sources in 
[index.php](/Users/tyemeclifford/Documents/GH/mediaplayer/index.php), 
[catalogue.php](/Users/tyemeclifford/Documents/GH/mediaplayer/catalogue.php), 
and [embed.php](/Users/tyemeclifford/Documents/GH/mediaplayer/embed.php) 
to use root/base-aware URLs.
This commit is contained in:
Ty Clifford
2026-06-24 13:25:44 -04:00
parent 1abe5218ca
commit 7ad9c672ca
4 changed files with 12 additions and 6 deletions
+1 -1
View File
@@ -127,7 +127,7 @@ render_head('Videos — TyClifford.com', '
<a class="cat-thumb" href="<?= h(public_video_url($vslug)) ?>" title="<?= h($vtitle) ?>">
<div class="cat-thumb-img">
<?php if ($vthumb): ?>
<img src="<?= h(MEDIA_URL . $vthumb) ?>" alt="<?= h($vtitle) ?>" loading="lazy">
<img src="<?= h(public_media_url($vthumb)) ?>" alt="<?= h($vtitle) ?>" loading="lazy">
<?php else: ?>
<div class="no-thumb">NO THUMBNAIL</div>
<?php endif; ?>
+2 -2
View File
@@ -21,7 +21,7 @@ $base_url = $scheme . '://' . $host . $script . '/'; // e.g. https://tyclifford
$player_sources = [];
if ($video && !empty($video['sources'])) {
foreach ($video['sources'] as $source) {
$player_source = source_player_data($source, $base_url . MEDIA_URL);
$player_source = source_player_data($source, public_absolute_url(public_media_url()));
if ($player_source) $player_sources[] = $player_source;
}
}
@@ -216,7 +216,7 @@ header('Content-Security-Policy: frame-ancestors *');
class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="metadata"
<?php if ($video['thumbnail']): ?>
poster="<?= htmlspecialchars($base_url . MEDIA_URL . $video['thumbnail'], ENT_QUOTES) ?>"
poster="<?= htmlspecialchars(public_absolute_url(public_media_url($video['thumbnail'])), ENT_QUOTES) ?>"
<?php endif; ?>>
<?php foreach ($native_player_sources as $src): ?>
<source
+6
View File
@@ -125,6 +125,12 @@ function public_url_path(string $path): string {
return $base . $path;
}
function public_media_url(string $path = ''): string {
$media_url = public_url_path('/media/');
$path = ltrim($path, '/');
return $path === '' ? $media_url : rtrim($media_url, '/') . '/' . $path;
}
function public_home_url(): string {
return url_rewrite_enabled() ? public_url_path('/') : public_url_path('/index.php');
}
+3 -3
View File
@@ -27,7 +27,7 @@ $paged = get_videos_paginated($page, $per_page);
$player_sources = [];
if ($video && !empty($video['sources'])) {
foreach ($video['sources'] as $source) {
$player_source = source_player_data($source);
$player_source = source_player_data($source, public_media_url());
if ($player_source) $player_sources[] = $player_source;
}
}
@@ -245,7 +245,7 @@ render_head('Media — TyClifford.com', '
class="video-js vjs-default-skin vjs-big-play-centered"
controls preload="metadata"
<?php if ($video['thumbnail']): ?>
poster="<?= h(MEDIA_URL . $video['thumbnail']) ?>"
poster="<?= h(public_media_url($video['thumbnail'])) ?>"
<?php endif; ?>
data-setup='{"fluid":false,"responsive":true,"playbackRates":[0.5,1,1.25,1.5,2]}'>
<?php foreach ($native_player_sources as $src): ?>
@@ -348,7 +348,7 @@ render_head('Media — TyClifford.com', '
<div class="cat-active-indicator"></div>
<div class="cat-thumb-img">
<?php if ($vthumb): ?>
<img src="<?= h(MEDIA_URL . $vthumb) ?>" alt="<?= h($vtitle) ?>" loading="lazy">
<img src="<?= h(public_media_url($vthumb)) ?>" alt="<?= h($vtitle) ?>" loading="lazy">
<?php else: ?>
<div class="no-thumb">NO THUMB</div>
<?php endif; ?>