update thumbnail logic to use [id]_thumb.jpg in out-dir
This commit is contained in:
parent
f91f84c12d
commit
663243e956
2 changed files with 8 additions and 6 deletions
|
|
@ -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 '';
|
||||
}
|
||||
|
|
|
|||
10
new.php
10
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);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue