mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-26 16:46:12 +01:00
feat: allow gif profile images, sharp 0.30.0 supports gifs
This commit is contained in:
@@ -46,6 +46,7 @@ image.resizeImage = async function (data) {
|
|||||||
const buffer = await fs.promises.readFile(data.path);
|
const buffer = await fs.promises.readFile(data.path);
|
||||||
const sharpImage = sharp(buffer, {
|
const sharpImage = sharp(buffer, {
|
||||||
failOnError: true,
|
failOnError: true,
|
||||||
|
animated: data.path.endsWith('gif'),
|
||||||
});
|
});
|
||||||
const metadata = await sharpImage.metadata();
|
const metadata = await sharpImage.metadata();
|
||||||
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ const db = require('../database');
|
|||||||
const file = require('../file');
|
const file = require('../file');
|
||||||
const image = require('../image');
|
const image = require('../image');
|
||||||
const meta = require('../meta');
|
const meta = require('../meta');
|
||||||
const plugins = require('../plugins');
|
|
||||||
|
|
||||||
module.exports = function (User) {
|
module.exports = function (User) {
|
||||||
User.getAllowedProfileImageExtensions = function () {
|
User.getAllowedProfileImageExtensions = function () {
|
||||||
@@ -21,11 +20,7 @@ module.exports = function (User) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
User.getAllowedImageTypes = function () {
|
User.getAllowedImageTypes = function () {
|
||||||
const allowedTypes = ['image/png', 'image/jpeg', 'image/bmp'];
|
return ['image/png', 'image/jpeg', 'image/bmp', 'image/gif'];
|
||||||
if (plugins.hooks.hasListeners('filter:image.isFileTypeAllowed')) {
|
|
||||||
allowedTypes.push('image/gif');
|
|
||||||
}
|
|
||||||
return allowedTypes;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
User.updateCoverPosition = async function (uid, position) {
|
User.updateCoverPosition = async function (uid, position) {
|
||||||
|
|||||||
Reference in New Issue
Block a user