diff options
author | Marc Alexander <admin@m-a-styles.de> | 2020-02-01 08:50:12 +0100 |
---|---|---|
committer | Marc Alexander <admin@m-a-styles.de> | 2020-02-01 08:50:12 +0100 |
commit | 7de24bad2e02ba6170cbfcfbaeac5a7a20ed3164 (patch) | |
tree | cd7105d198278f9779dc2d433115901329b93645 | |
parent | Merge pull request #5834 from mrgoldy/ticket/15370 (diff) | |
parent | [ticket/16329] Add configuration options for Plupload (diff) | |
download | phpbb-7de24bad2e02ba6170cbfcfbaeac5a7a20ed3164.tar.gz phpbb-7de24bad2e02ba6170cbfcfbaeac5a7a20ed3164.tar.bz2 phpbb-7de24bad2e02ba6170cbfcfbaeac5a7a20ed3164.zip |
Merge pull request #5832 from KYPREO/ticket/16329origin/3.2.x
[ticket/16329] Add configuration options for Plupload
-rw-r--r-- | phpBB/includes/acp/acp_attachments.php | 2 | ||||
-rw-r--r-- | phpBB/install/schemas/schema_data.sql | 2 | ||||
-rw-r--r-- | phpBB/language/en/acp/attachments.php | 4 | ||||
-rw-r--r-- | phpBB/phpbb/db/migration/data/v32x/add_plupload_config.php | 30 | ||||
-rw-r--r-- | phpBB/phpbb/plupload/plupload.php | 7 | ||||
-rw-r--r-- | tests/plupload/plupload_test.php | 10 |
6 files changed, 51 insertions, 4 deletions
diff --git a/phpBB/includes/acp/acp_attachments.php b/phpBB/includes/acp/acp_attachments.php index 94e3660de8..6298c7b0f2 100644 --- a/phpBB/includes/acp/acp_attachments.php +++ b/phpBB/includes/acp/acp_attachments.php @@ -169,6 +169,8 @@ class acp_attachments 'img_max_thumb_width' => array('lang' => 'MAX_THUMB_WIDTH', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), 'img_min_thumb_filesize' => array('lang' => 'MIN_THUMB_FILESIZE', 'validate' => 'int:0:999999999999999', 'type' => 'number:0:999999999999999', 'explain' => true, 'append' => ' ' . $user->lang['BYTES']), 'img_max' => array('lang' => 'MAX_IMAGE_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), + 'img_strip_metadata' => array('lang' => 'IMAGE_STRIP_METADATA', 'validate' => 'bool', 'type' => 'radio:yes_no', 'explain' => true), + 'img_quality' => array('lang' => 'IMAGE_QUALITY', 'validate' => 'int:50:90', 'type' => 'number:50:90', 'explain' => true, 'append' => ' %'), 'img_link' => array('lang' => 'IMAGE_LINK_SIZE', 'validate' => 'int:0:9999', 'type' => 'dimension:0:9999', 'explain' => true, 'append' => ' ' . $user->lang['PIXEL']), ) ); diff --git a/phpBB/install/schemas/schema_data.sql b/phpBB/install/schemas/schema_data.sql index 86c8f00a24..52c6061eb4 100644 --- a/phpBB/install/schemas/schema_data.sql +++ b/phpBB/install/schemas/schema_data.sql @@ -155,6 +155,8 @@ INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_height', ' INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_thumb_width', '400'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_max_width', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_min_thumb_filesize', '12000'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_quality', '85'); +INSERT INTO phpbb_config (config_name, config_value) VALUES ('img_strip_metadata', '0'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_check', '3'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_max', '50'); INSERT INTO phpbb_config (config_name, config_value) VALUES ('ip_login_limit_time', '21600'); diff --git a/phpBB/language/en/acp/attachments.php b/phpBB/language/en/acp/attachments.php index 86430f46bd..d4768cae07 100644 --- a/phpBB/language/en/acp/attachments.php +++ b/phpBB/language/en/acp/attachments.php @@ -111,6 +111,10 @@ $lang = array_merge($lang, array( 'IMAGE_LINK_SIZE' => 'Image link dimensions', 'IMAGE_LINK_SIZE_EXPLAIN' => 'Display image attachment as an inline text link if image is larger than this. To disable this behaviour, set the values to 0px by 0px.', + 'IMAGE_QUALITY' => 'Quality of uploaded image attachments (JPEG only)', + 'IMAGE_QUALITY_EXPLAIN' => 'Specify value between 50% (smaller file size) and 90% (higher quality). Quality higher than 90% increases filesize and is disabled. Setting only applies if maximum image dimensions are set to a value other than 0px by 0px.', + 'IMAGE_STRIP_METADATA' => 'Strip image metadata (JPEG only)', + 'IMAGE_STRIP_METADATA_EXPLAIN' => 'Strip Exif metadata, e.g. author name, GPS coordinates and camera details. Setting only applies if maximum image dimensions are set to a value other than 0px by 0px.', 'MAX_ATTACHMENTS' => 'Maximum number of attachments per post', 'MAX_ATTACHMENTS_PM' => 'Maximum number of attachments per private message', diff --git a/phpBB/phpbb/db/migration/data/v32x/add_plupload_config.php b/phpBB/phpbb/db/migration/data/v32x/add_plupload_config.php new file mode 100644 index 0000000000..d708155807 --- /dev/null +++ b/phpBB/phpbb/db/migration/data/v32x/add_plupload_config.php @@ -0,0 +1,30 @@ +<?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\v32x; + +class add_plupload_config extends \phpbb\db\migration\migration +{ + static public function depends_on() + { + return ['\phpbb\db\migration\data\v32x\v329']; + } + + public function update_data() + { + return [ + ['config.add', ['img_quality', '85']], + ['config.add', ['img_strip_metadata', '0']], + ]; + } +} diff --git a/phpBB/phpbb/plupload/plupload.php b/phpBB/phpbb/plupload/plupload.php index 5a5b8a1874..6f9e39c384 100644 --- a/phpBB/phpbb/plupload/plupload.php +++ b/phpBB/phpbb/plupload/plupload.php @@ -263,10 +263,13 @@ class plupload $resize = ''; if ($this->config['img_max_height'] > 0 && $this->config['img_max_width'] > 0) { + $preserve_headers_value = $this->config['img_strip_metadata'] ? 'false' : 'true'; $resize = sprintf( - 'resize: {width: %d, height: %d, quality: 85},', + 'resize: {width: %d, height: %d, quality: %d, preserve_headers: %s},', (int) $this->config['img_max_width'], - (int) $this->config['img_max_height'] + (int) $this->config['img_max_height'], + (int) $this->config['img_quality'], + $preserve_headers_value ); } diff --git a/tests/plupload/plupload_test.php b/tests/plupload/plupload_test.php index eb4657afbc..206029d8b8 100644 --- a/tests/plupload/plupload_test.php +++ b/tests/plupload/plupload_test.php @@ -19,12 +19,16 @@ class phpbb_plupload_test extends phpbb_test_case array( 0, 0, + 85, + 0, '', ), array( 130, 150, - 'resize: {width: 130, height: 150, quality: 85},' + 85, + 1, + 'resize: {width: 130, height: 150, quality: 85, preserve_headers: false},' ), ); } @@ -32,7 +36,7 @@ class phpbb_plupload_test extends phpbb_test_case /** * @dataProvider generate_resize_string_data */ - public function test_generate_resize_string($config_width, $config_height, $expected) + public function test_generate_resize_string($config_width, $config_height, $config_quality, $config_metadata, $expected) { global $phpbb_root_path, $phpEx; @@ -41,6 +45,8 @@ class phpbb_plupload_test extends phpbb_test_case $config = new \phpbb\config\config(array( 'img_max_width' => $config_width, 'img_max_height' => $config_height, + 'img_quality' => $config_quality, + 'img_strip_metadata' => $config_metadata, 'upload_path' => 'files', )); $plupload = new \phpbb\plupload\plupload( |