feat: allow gif profile images, sharp 0.30.0 supports gifs

isekai-main
Barış Soner Uşaklı 3 years ago
parent b71025cee9
commit 7f1c4477e3

@ -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();

@ -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) {

Loading…
Cancel
Save