allow screenshot from game as thumbnail header
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
import sharp from 'sharp';
|
||||
sharp.cache({ files : 0 });
|
||||
|
||||
const collection = 'games';
|
||||
/**
|
||||
@@ -11,7 +13,7 @@ class GamesManager{
|
||||
* @param {App} app Class initializer, основна апликация
|
||||
*/
|
||||
init(app){
|
||||
const {db, am} = app;
|
||||
const {db, am, config} = app;
|
||||
|
||||
/**
|
||||
* Creates a new game definition, създаване на нова игрова дефиниция
|
||||
@@ -69,6 +71,14 @@ class GamesManager{
|
||||
project: { name:1, id:1, thumb: 1}
|
||||
});
|
||||
}
|
||||
|
||||
this.setHeader = async function(ctx, id, file){
|
||||
await sharp(file.path).resize({height: 500}).webp({quality: 75}).toFile(`${config.fs.repo}/thumb/${id}.webp`);
|
||||
await sharp(file.path).webp({quality: 75}).toFile(`${config.fs.repo}/default/${id}.webp`);
|
||||
let object = await this.read(id);
|
||||
object.thumb = id;
|
||||
await this.update(ctx, object);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user