mirror of
https://github.com/discourse/discourse.git
synced 2024-11-28 03:33:58 -06:00
BUGFIX: check image size before uploading an avatar/background
This commit is contained in:
parent
faa341148e
commit
7fd0db857f
@ -40,11 +40,14 @@ Discourse.AvatarSelectorView = Discourse.ModalBodyView.extend({
|
||||
});
|
||||
|
||||
// when a file has been selected
|
||||
$upload.on("fileuploadadd", function () {
|
||||
$upload.on('fileuploadsubmit', function (e, data) {
|
||||
var result = Discourse.Utilities.validateUploadedFiles(data.files);
|
||||
self.setProperties({
|
||||
uploading: true,
|
||||
uploadProgress: 0,
|
||||
uploading: result,
|
||||
imageIsNotASquare: false
|
||||
});
|
||||
return result;
|
||||
});
|
||||
|
||||
// when there is a progression for the upload
|
||||
|
@ -9,25 +9,27 @@
|
||||
Discourse.PreferencesView = Discourse.View.extend({
|
||||
templateName: 'user/preferences',
|
||||
classNames: ['user-preferences'],
|
||||
|
||||
|
||||
uploading: false,
|
||||
uploadProgress: 0,
|
||||
|
||||
|
||||
didInsertElement: function() {
|
||||
var self = this;
|
||||
var $upload = $("#profile-background-input");
|
||||
|
||||
|
||||
this._super();
|
||||
|
||||
|
||||
$upload.fileupload({
|
||||
url: Discourse.getURL("/users/" + this.get('controller.model.username') + "/preferences/user_image"),
|
||||
dataType: "json",
|
||||
fileInput: $upload,
|
||||
formData: { user_image_type: "profile_background" }
|
||||
});
|
||||
|
||||
$upload.on("fileuploadadd", function() {
|
||||
self.set("uploading", true);
|
||||
|
||||
$upload.on('fileuploadsubmit', function (e, data) {
|
||||
var result = Discourse.Utilities.validateUploadedFiles(data.files);
|
||||
self.setProperties({ uploadProgress: 0, uploading: result });
|
||||
return result;
|
||||
});
|
||||
$upload.on("fileuploadprogressall", function(e, data) {
|
||||
var progress = parseInt(data.loaded / data.total * 100, 10);
|
||||
@ -51,5 +53,3 @@ Discourse.PreferencesView = Discourse.View.extend({
|
||||
$("#profile-background-input").fileupload("destroy");
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user