mirror of
https://github.com/phpbb/phpbb.git
synced 2025-08-12 03:34:04 +02:00
Merge pull request #5979 from gijsmartens/ticket/15769
[ticket/15769] Crop avatar on upload
This commit is contained in:
@@ -23,7 +23,7 @@ use phpbb\storage\exception\exception as storage_exception;
|
||||
use phpbb\storage\storage;
|
||||
|
||||
/**
|
||||
* Handles avatars uploaded to the board
|
||||
* Handles avatars uploaded to the board.
|
||||
*/
|
||||
class upload extends \phpbb\avatar\driver\driver
|
||||
{
|
||||
@@ -100,10 +100,14 @@ class upload extends \phpbb\avatar\driver\driver
|
||||
return false;
|
||||
}
|
||||
|
||||
$template->assign_vars(array(
|
||||
'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'],
|
||||
$use_board = defined('PHPBB_USE_BOARD_URL_PATH') && PHPBB_USE_BOARD_URL_PATH;
|
||||
$web_path = $use_board ? generate_board_url() . '/' : $this->path_helper->get_web_root_path();
|
||||
|
||||
$template->assign_vars([
|
||||
'AVATAR_ALLOWED_EXTENSIONS' => implode(',', preg_replace('/^/', '.', $this->allowed_extensions)),
|
||||
));
|
||||
'AVATAR_UPLOAD_SIZE' => $this->config['avatar_filesize'],
|
||||
'T_ASSETS_PATH' => $web_path . '/assets',
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -137,6 +141,7 @@ class upload extends \phpbb\avatar\driver\driver
|
||||
return false;
|
||||
}
|
||||
|
||||
/** @var \phpbb\files\filespec_storage $file */
|
||||
$file = $upload->handle_upload('files.types.form_storage', 'avatar_upload_file');
|
||||
|
||||
$prefix = $this->config['avatar_salt'] . '_';
|
||||
@@ -226,7 +231,6 @@ class upload extends \phpbb\avatar\driver\driver
|
||||
*/
|
||||
public function delete($row)
|
||||
{
|
||||
|
||||
$error = array();
|
||||
$prefix = $this->config['avatar_salt'] . '_';
|
||||
$ext = substr(strrchr($row['avatar'], '.'), 1);
|
||||
|
40
phpBB/phpbb/db/migration/data/v400/increase_avatar_size.php
Normal file
40
phpBB/phpbb/db/migration/data/v400/increase_avatar_size.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
/**
|
||||
*
|
||||
* This file is part of the phpBB Forum Software package.
|
||||
*
|
||||
* @copyright (c) phpBB Limited <https://www.phpbb.com>
|
||||
* @license GNU General Public License, version 2 (GPL-2.0)
|
||||
*
|
||||
* For full copyright and license information, please see
|
||||
* the docs/CREDITS.txt file.
|
||||
*
|
||||
*/
|
||||
|
||||
namespace phpbb\db\migration\data\v400;
|
||||
|
||||
use phpbb\db\migration\container_aware_migration;
|
||||
|
||||
class increase_avatar_size extends container_aware_migration
|
||||
{
|
||||
public static function depends_on()
|
||||
{
|
||||
return ['\phpbb\db\migration\data\v400\dev'];
|
||||
}
|
||||
|
||||
public function update_data()
|
||||
{
|
||||
return [
|
||||
['custom', [[$this, 'increase_size']]],
|
||||
];
|
||||
}
|
||||
|
||||
public function increase_size(): void
|
||||
{
|
||||
$this->config->set('avatar_filesize', max(262144, $this->config['avatar_filesize'])); // Increase to 256 KiB
|
||||
$this->config->set('avatar_max_height', max('120', $this->config['avatar_max_height'])); // Increase to max 120px height
|
||||
$this->config->set('avatar_max_width', max('120', $this->config['avatar_max_width'])); // Increase to max 120px width
|
||||
$this->config->set('avatar_min_height', max('40', $this->config['avatar_min_height'])); // Increase to min 40px height
|
||||
$this->config->set('avatar_min_width', max('40', $this->config['avatar_min_width'])); // Increase to max 40px width
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user