diff --git a/public/src/client/account/edit.js b/public/src/client/account/edit.js index 20e85bb46b..13b84e3023 100644 --- a/public/src/client/account/edit.js +++ b/public/src/client/account/edit.js @@ -241,22 +241,29 @@ define('forum/account/edit', ['forum/account/header', 'translator', 'components' uploadModal.find('.upload-btn').on('click', function () { var url = uploadModal.find('#uploadFromUrl').val(); if (!url) { - return; + return false; } - - uploadModal.modal('hide'); - - pictureCropper.handleImageCrop({ + socket.emit('user.uploadProfileImageFromUrl', { + uid: ajaxify.data.uid, url: url, - socketMethod: 'user.uploadCroppedPicture', - aspectRatio: '1 / 1', - allowSkippingCrop: false, - restrictImageDimension: true, - imageDimension: ajaxify.data.profileImageDimension, - paramName: 'uid', - paramValue: ajaxify.data.theirid, - }, onUploadComplete); + }, function (err, url) { + if (err) { + return app.alertError(err); + } + uploadModal.modal('hide'); + + pictureCropper.handleImageCrop({ + url: url, + socketMethod: 'user.uploadCroppedPicture', + aspectRatio: '1 / 1', + allowSkippingCrop: false, + restrictImageDimension: true, + imageDimension: ajaxify.data.profileImageDimension, + paramName: 'uid', + paramValue: ajaxify.data.theirid, + }, onUploadComplete); + }); return false; }); }); diff --git a/src/user/picture.js b/src/user/picture.js index be489364b9..13288774b2 100644 --- a/src/user/picture.js +++ b/src/user/picture.js @@ -50,12 +50,7 @@ module.exports = function (User) { }, next); }, function (image, next) { - User.setUserFields(uid, { - uploadedpicture: image.url, - picture: image.url, - }, function (err) { - next(err, image); - }); + next(null, image); }, ], callback); };