|
|
|
@ -37,10 +37,18 @@ module.exports = function(User) {
|
|
|
|
|
function(next) {
|
|
|
|
|
next(!extension ? new Error('[[error:invalid-image-extension]]') : null);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
if (plugins.hasListeners('filter:uploadImage')) {
|
|
|
|
|
return plugins.fireHook('filter:uploadImage', {image: picture, uid: updateUid}, next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var filename = updateUid + '-profileimg' + (convertToPNG ? '.png' : extension);
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function(next) {
|
|
|
|
|
file.isFileTypeAllowed(picture.path, next);
|
|
|
|
|
},
|
|
|
|
|
function(path, next) {
|
|
|
|
|
function(next) {
|
|
|
|
|
image.resizeImage({
|
|
|
|
|
path: picture.path,
|
|
|
|
|
extension: extension,
|
|
|
|
@ -55,14 +63,6 @@ module.exports = function(User) {
|
|
|
|
|
next();
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
if (plugins.hasListeners('filter:uploadImage')) {
|
|
|
|
|
return plugins.fireHook('filter:uploadImage', {image: picture, uid: updateUid}, next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var filename = updateUid + '-profileimg' + (convertToPNG ? '.png' : extension);
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function(next) {
|
|
|
|
|
User.getUserField(updateUid, 'uploadedpicture', next);
|
|
|
|
|
},
|
|
|
|
@ -167,12 +167,9 @@ module.exports = function(User) {
|
|
|
|
|
}, next);
|
|
|
|
|
},
|
|
|
|
|
function(next) {
|
|
|
|
|
file.isFileTypeAllowed(data.file.path, next);
|
|
|
|
|
},
|
|
|
|
|
function(tempPath, next) {
|
|
|
|
|
var image = {
|
|
|
|
|
name: 'profileCover',
|
|
|
|
|
path: tempPath,
|
|
|
|
|
path: data.file.path,
|
|
|
|
|
uid: data.uid
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
@ -181,16 +178,20 @@ module.exports = function(User) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var filename = data.uid + '-profilecover';
|
|
|
|
|
file.saveFileToLocal(filename, 'profile', image.path, function(err, upload) {
|
|
|
|
|
if (err) {
|
|
|
|
|
return next(err);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async.waterfall([
|
|
|
|
|
function (next) {
|
|
|
|
|
file.isFileTypeAllowed(data.file.path, next);
|
|
|
|
|
},
|
|
|
|
|
function (next) {
|
|
|
|
|
file.saveFileToLocal(filename, 'profile', image.path, next);
|
|
|
|
|
},
|
|
|
|
|
function (upload, next) {
|
|
|
|
|
next(null, {
|
|
|
|
|
url: nconf.get('relative_path') + upload.url,
|
|
|
|
|
name: image.name
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
], next);
|
|
|
|
|
},
|
|
|
|
|
function(uploadData, next) {
|
|
|
|
|
url = uploadData.url;
|
|
|
|
|