[ticket/15769] Adjust loading of images for cropping and add some docblocks

PHPBB3-15769
This commit is contained in:
Marc Alexander 2021-08-20 18:35:20 +02:00
parent 1933a8ab47
commit b3308245c3
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
2 changed files with 17 additions and 1 deletions

View file

@ -44,7 +44,15 @@
// Correctly position the cropper buttons
this.$buttons.appendTo(this.$box);
this.image = this.$box.children('img');
// Ensure we have an img for the cropping
if (this.$box.children('img').length === 0) {
const $avatarImg = $('<img/>');
$avatarImg.addClass('avatar');
this.image = $avatarImg;
this.$box.prepend($avatarImg);
} else {
this.image = this.$box.children('img');
}
this.bindInput();
this.bindSelect();
@ -111,6 +119,9 @@
});
},
/**
* Bind submit button to be handled by ajax submit
*/
bindSubmit() {
const $this = this;
$this.$form = this.$input.closest('form');
@ -160,6 +171,10 @@
return originalName.replace(/\.[^/\\.]+$/, '.png');
},
/**
* Handle response from avatar submission
* @param {Object} response AJAX response object
*/
uploadDone(response) {
if (typeof response !== 'object') {
return;

View file

@ -359,6 +359,7 @@ ol.def-rules li {
.c-cropper-avatar-box {
min-height: 240px;
max-height: 400px;
}
p.notification-title,