[ticket/15769] Make basic upload, refresh, and errors work

PHPBB3-15769
This commit is contained in:
Marc Alexander 2021-08-20 16:57:36 +02:00
parent b72379aaab
commit 1933a8ab47
No known key found for this signature in database
GPG key ID: 50E0D2423696F995
4 changed files with 27 additions and 14 deletions

View file

@ -165,17 +165,17 @@
return; return;
} }
// trigger_error() was called which likely means a permission error was encountered.
if (typeof response.title !== 'undefined') {
return;
}
// Handle errors while deleting file // Handle errors while deleting file
if (typeof response.error !== 'undefined') { if (typeof response.error !== 'undefined') {
phpbb.alert(response.error.title, response.error.message); phpbb.alert(response.error.title, response.error.messages.join('<br>'));
} } else {
alert = phpbb.alert(response.MESSAGE_TITLE, response.MESSAGE_TEXT);
phpbb.avatars.destroy(); setTimeout(function() {
window.location = response.REFRESH_DATA.url.replace('&amp;', '&');
}, response.REFRESH_DATA.time * 1000);
phpbb.avatars.destroy();
}
}, },
/** /**

View file

@ -711,6 +711,19 @@ class ucp_profile
trigger_error($message); trigger_error($message);
} }
} }
else if ($request->is_ajax())
{
$error = $phpbb_avatar_manager->localize_errors($user, $error);
$json_response = new \phpbb\json_response;
$json_response->send([
'success' => false,
'error' => [
'title' => $language->lang('INFORMATION'),
'messages' => $error,
],
]);
}
} }
} }
else else

View file

@ -107,7 +107,7 @@ class upload extends \phpbb\avatar\driver\driver
$template->assign_vars([ $template->assign_vars([
'AVATAR_ALLOWED_EXTENSIONS' => implode(',', preg_replace('/^/', '.', $this->allowed_extensions)), 'AVATAR_ALLOWED_EXTENSIONS' => implode(',', preg_replace('/^/', '.', $this->allowed_extensions)),
'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'], 'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'],
'S_CROPPING_AVAILABLE' => image_cropper::is_available(), 'S_CROPPING_AVAILABLE' => true,
'T_ASSETS_PATH' => $web_path . '/assets', 'T_ASSETS_PATH' => $web_path . '/assets',
]); ]);

View file

@ -31,10 +31,10 @@ class increase_avatar_size extends container_aware_migration
public function increase_size(): void public function increase_size(): void
{ {
$this->config['avatar_filesize'] = max(262144, $this->config['avatar_filesize']); // Increase to 256 KiB $this->config->set('avatar_filesize', max(262144, $this->config['avatar_filesize'])); // Increase to 256 KiB
$this->config['avatar_max_height'] = max('120', $this->config['avatar_max_height']); // Increase to max 120px height $this->config->set('avatar_max_height', max('120', $this->config['avatar_max_height'])); // Increase to max 120px height
$this->config['avatar_max_width'] = max('120', $this->config['avatar_max_width']); // Increase to max 120px width $this->config->set('avatar_max_width', max('120', $this->config['avatar_max_width'])); // Increase to max 120px width
$this->config['avatar_min_height'] = max('40', $this->config['avatar_min_height']); // Increase to min 40px height $this->config->set('avatar_min_height', max('40', $this->config['avatar_min_height'])); // Increase to min 40px height
$this->config['avatar_min_width'] = max('40', $this->config['avatar_min_width']); // Increase to max 40px width $this->config->set('avatar_min_width', max('40', $this->config['avatar_min_width'])); // Increase to max 40px width
} }
} }