Merge pull request #196 from lsaa/disable-thumbnails

Add option to disable thumbnail generation
This commit is contained in:
Cohee
2023-04-29 01:09:07 +03:00
committed by GitHub
2 changed files with 7 additions and 1 deletions

View File

@@ -4,10 +4,11 @@ const whitelist = ['127.0.0.1']; //Example for add several IP in whitelist: ['12
const whitelistMode = true; //Disabling enabling the ip whitelist mode. true/false const whitelistMode = true; //Disabling enabling the ip whitelist mode. true/false
const basicAuthMode = false; //Toggle basic authentication for endpoints. const basicAuthMode = false; //Toggle basic authentication for endpoints.
const basicAuthUser = {username: "user", password: "password"}; //Login credentials when basicAuthMode is true. const basicAuthUser = {username: "user", password: "password"}; //Login credentials when basicAuthMode is true.
const disableThumbnails = false; //Disables the generation of thumbnails, opting to use the raw images instead
const autorun = true; //Autorun in the browser. true/false const autorun = true; //Autorun in the browser. true/false
const enableExtensions = true; //Enables support for TavernAI-extras project const enableExtensions = true; //Enables support for TavernAI-extras project
const listen = true; // If true, Can be access from other device or PC. otherwise can be access only from hosting machine. const listen = true; // If true, Can be access from other device or PC. otherwise can be access only from hosting machine.
module.exports = { module.exports = {
port, whitelist, whitelistMode, basicAuthMode, basicAuthUser, autorun, enableExtensions, listen port, whitelist, whitelistMode, basicAuthMode, basicAuthUser, autorun, enableExtensions, listen, disableThumbnails
}; };

View File

@@ -2098,6 +2098,11 @@ app.get('/thumbnail', jsonParser, async function (request, response) {
return response.sendStatus(403); return response.sendStatus(403);
} }
if (config.disableThumbnails == true) {
const pathToOriginalFile = path.join(getOriginalFolder(type), file);
return response.sendFile(pathToOriginalFile, { root: __dirname });
}
const pathToCachedFile = await generateThumbnail(type, file); const pathToCachedFile = await generateThumbnail(type, file);
if (!pathToCachedFile) { if (!pathToCachedFile) {