From 663243e95668d9c48b59d1c6a42e4ed117f430af Mon Sep 17 00:00:00 2001 From: hbrain Date: Tue, 2 Jun 2026 07:58:40 +0200 Subject: [PATCH] update thumbnail logic to use [id]_thumb.jpg in out-dir --- index.php | 4 ++-- new.php | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/index.php b/index.php index ac9616f..95f87d2 100644 --- a/index.php +++ b/index.php @@ -62,8 +62,8 @@ function video_thumb_public_url($config, $videoName){ if ($videoName === '') return ''; $base = pathinfo($videoName, PATHINFO_FILENAME); foreach (['jpg','jpeg','png','webp','gif'] as $ext) { - $file = $config['thumbs_dir'] . '/' . $base . '.' . $ext; - if (is_file($file)) return $config['public_thumbs'] . '/' . rawurlencode($base . '.' . $ext) . '?v=' . filemtime($file); + $file = $config['videos_dir'] . '/' . $base . '_thumb.' . $ext; + if (is_file($file)) return $config['public_videos'] . '/' . rawurlencode($base . '_thumb.' . $ext) . '?v=' . filemtime($file); } return ''; } diff --git a/new.php b/new.php index 95701e6..ef937f7 100644 --- a/new.php +++ b/new.php @@ -576,8 +576,8 @@ function video_thumb_public_url($config, $videoName){ if ($videoName === '') return ''; $base = pathinfo($videoName, PATHINFO_FILENAME); foreach (['jpg','jpeg','png','webp','gif'] as $ext) { - $file = $config['thumbs_dir'] . '/' . $base . '.' . $ext; - if (is_file($file)) return $config['public_thumbs'] . '/' . rawurlencode($base . '.' . $ext) . '?v=' . filemtime($file); + $file = $config['videos_dir'] . '/' . $base . '_thumb.' . $ext; + if (is_file($file)) return $config['public_videos'] . '/' . rawurlencode($base . '_thumb.' . $ext) . '?v=' . filemtime($file); } return ''; } @@ -861,15 +861,17 @@ try { if (!$outputs) throw new RuntimeException('No rendered video found for this input directory yet.'); $src = $dir . '/' . $file; - $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION)); $written = []; foreach ($outputs as $out) { $base = pathinfo($out, PATHINFO_FILENAME); + // Remove any old thumbnail files in thumbs_dir foreach (['jpg','jpeg','png','webp','gif'] as $oldExt) { $old = $config['thumbs_dir'] . '/' . $base . '.' . $oldExt; if (is_file($old)) @unlink($old); } - $target = $config['thumbs_dir'] . '/' . $base . '.' . $ext; + + // Copy new thumbnail to videos_dir with _thumb.jpg suffix + $target = $config['videos_dir'] . '/' . $base . '_thumb.jpg'; if (!@copy($src, $target)) throw new RuntimeException('Failed to write thumbnail.'); @chmod($target, 0664); $written[] = basename($target);