mirror of
https://github.com/plankanban/planka.git
synced 2025-12-17 17:23:25 +03:00
fix: Fix image size for animated attachments
This commit is contained in:
@@ -46,18 +46,20 @@ module.exports = {
|
|||||||
const thumbnailsPath = path.join(rootPath, 'thumbnails');
|
const thumbnailsPath = path.join(rootPath, 'thumbnails');
|
||||||
fs.mkdirSync(thumbnailsPath);
|
fs.mkdirSync(thumbnailsPath);
|
||||||
|
|
||||||
const extension = metadata.format === 'jpeg' ? 'jpg' : metadata.format;
|
const { width, pageHeight: height = metadata.height } = metadata;
|
||||||
|
const thumbnailsExtension = metadata.format === 'jpeg' ? 'jpg' : metadata.format;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await image
|
await image
|
||||||
.resize(256, metadata.height > metadata.width ? 320 : undefined, {
|
.resize(256, height > width ? 320 : undefined, {
|
||||||
kernel: sharp.kernel.nearest,
|
kernel: sharp.kernel.nearest,
|
||||||
})
|
})
|
||||||
.toFile(path.join(thumbnailsPath, `cover-256.${extension}`));
|
.toFile(path.join(thumbnailsPath, `cover-256.${thumbnailsExtension}`));
|
||||||
|
|
||||||
fileData.image = {
|
fileData.image = {
|
||||||
..._.pick(metadata, ['width', 'height']),
|
width,
|
||||||
thumbnailsExtension: extension,
|
height,
|
||||||
|
thumbnailsExtension,
|
||||||
};
|
};
|
||||||
} catch (error1) {
|
} catch (error1) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user