add proper thumbnail fallback
This commit is contained in:
1 parent
66474f50f7
commit
dd04dcbffa
1 file changed
+17
@@ -15,6 +15,23 @@ export class CdnResolver {
|
||||
return send403(res);
|
||||
}
|
||||
|
||||
if (!fs.existsSync(filePath) && path.extname(filePath).toLowerCase() === '.webp') {
|
||||
const parsedDisk = path.parse(filePath);
|
||||
const parsedUrl = path.posix.parse(reqPath);
|
||||
|
||||
for (const vidExt of CONFIG.SUPPORTED_VIDEOS) {
|
||||
const candidateVideo = path.join(parsedDisk.dir, `${parsedDisk.name}${vidExt}`);
|
||||
if (fs.existsSync(candidateVideo) && fs.statSync(candidateVideo).isFile()) {
|
||||
const candidateRelUrl = path.posix.join(parsedUrl.dir, `${parsedUrl.name}${vidExt}`);
|
||||
const cachedThumb = MediaService.getOrCreateVideoThumb(candidateVideo, candidateRelUrl);
|
||||
if (cachedThumb) {
|
||||
filePath = cachedThumb;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!fs.existsSync(filePath)) {
|
||||
return send404(res);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user