From b3308245c38f8465b5451a35b5c443d111fd1190 Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Fri, 20 Aug 2021 18:35:20 +0200 Subject: [PATCH] [ticket/15769] Adjust loading of images for cropping and add some docblocks PHPBB3-15769 --- phpBB/assets/javascript/phpbb-avatars.js | 17 ++++++++++++++++- phpBB/styles/prosilver/theme/cp.css | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/phpBB/assets/javascript/phpbb-avatars.js b/phpBB/assets/javascript/phpbb-avatars.js index 7c0a7e82d2..8ee5daf46d 100644 --- a/phpBB/assets/javascript/phpbb-avatars.js +++ b/phpBB/assets/javascript/phpbb-avatars.js @@ -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 = $(''); + $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; diff --git a/phpBB/styles/prosilver/theme/cp.css b/phpBB/styles/prosilver/theme/cp.css index a64a2d2cb3..7daaccb08e 100644 --- a/phpBB/styles/prosilver/theme/cp.css +++ b/phpBB/styles/prosilver/theme/cp.css @@ -359,6 +359,7 @@ ol.def-rules li { .c-cropper-avatar-box { min-height: 240px; + max-height: 400px; } p.notification-title,