Skip to content

Node.js based forum software built for the modern web

feat: allow gif profile images, sharp 0.30.0 supports gifs

Barış Soner Uşaklı7f1c4477e3b7
diff --git a/src/image.js b/src/image.js
index d1bb1de23e..f1cce078cb 100644
--- a/src/image.js
+++ b/src/image.js
@@ -46,6 +46,7 @@ image.resizeImage = async function (data) {
const buffer = await fs.promises.readFile(data.path);
const sharpImage = sharp(buffer, {
failOnError: true,
+ animated: data.path.endsWith('gif'),
});
const metadata = await sharpImage.metadata();
diff --git a/src/user/picture.js b/src/user/picture.js
index 3cc8d2932e..d3d2a22f68 100644
--- a/src/user/picture.js
+++ b/src/user/picture.js
@@ -9,7 +9,6 @@ const db = require('../database');
const file = require('../file');
const image = require('../image');
const meta = require('../meta');
-const plugins = require('../plugins');
module.exports = function (User) {
User.getAllowedProfileImageExtensions = function () {
@@ -21,11 +20,7 @@ module.exports = function (User) {
};
User.getAllowedImageTypes = function () {
- const allowedTypes = ['image/png', 'image/jpeg', 'image/bmp'];
- if (plugins.hooks.hasListeners('filter:image.isFileTypeAllowed')) {
- allowedTypes.push('image/gif');
- }
- return allowedTypes;
+ return ['image/png', 'image/jpeg', 'image/bmp', 'image/gif'];
};
User.updateCoverPosition = async function (uid, position) {