From afbf7aadd2db8756c8c003dfafd94862563869c8 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Thu, 21 Oct 2021 21:47:14 +0200 Subject: [PATCH] [ticket/16899] Add SVG and WEBP image type to ranks, smilies and topic icons PHPBB3-16899 --- phpBB/includes/acp/acp_icons.php | 34 +++++++++++++----------- phpBB/includes/acp/acp_ranks.php | 4 +-- phpBB/includes/functions_admin.php | 2 +- phpBB/styles/prosilver/theme/content.css | 4 +++ 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 6429424983..b1d4d2a27a 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -91,29 +91,33 @@ class acp_icons { $img_size = getimagesize($phpbb_root_path . $img_path . '/' . $path . $img); - if (!$img_size[0] || !$img_size[1] || strlen($img) > 255) + if ($img_size) { - continue; - } - - // adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons) - if ($mode == 'icons') - { - if ($img_size[0] > 127 && $img_size[0] > $img_size[1]) + if (!$img_size[0] || !$img_size[1] || strlen($img) > 255) { - $img_size[1] = (int) ($img_size[1] * (127 / $img_size[0])); - $img_size[0] = 127; + continue; } - else if ($img_size[1] > 127) + + // adjust the width and height to be lower than 128px while perserving the aspect ratio (for icons) + if ($mode == 'icons') { - $img_size[0] = (int) ($img_size[0] * (127 / $img_size[1])); - $img_size[1] = 127; + if ($img_size[0] > 127 && $img_size[0] > $img_size[1]) + { + $img_size[1] = (int) ($img_size[1] * (127 / $img_size[0])); + $img_size[0] = 127; + } + else if ($img_size[1] > 127) + { + $img_size[0] = (int) ($img_size[0] * (127 / $img_size[1])); + $img_size[1] = 127; + } } } $_images[$path . $img]['file'] = $path . $img; - $_images[$path . $img]['width'] = $img_size[0]; - $_images[$path . $img]['height'] = $img_size[1]; + + $_images[$path . $img]['width'] = $img_size ? $img_size[0] : ''; + $_images[$path . $img]['height'] = $img_size ? $img_size[1] : ''; } } unset($imglist); diff --git a/phpBB/includes/acp/acp_ranks.php b/phpBB/includes/acp/acp_ranks.php index 47e4e85aa1..c904e0cdf5 100644 --- a/phpBB/includes/acp/acp_ranks.php +++ b/phpBB/includes/acp/acp_ranks.php @@ -55,8 +55,8 @@ class acp_ranks $min_posts = ($special_rank) ? 0 : max(0, $request->variable('min_posts', 0)); $rank_image = $request->variable('rank_image', ''); - // The rank image has to be a jpg, gif or png - if ($rank_image != '' && !preg_match('#(\.gif|\.png|\.jpg|\.jpeg)$#i', $rank_image)) + // The rank image has to be a jp(e)g, gif, png, svg or webp + if ($rank_image != '' && !preg_match('#(\.gif|\.png|\.jpg|\.jpeg|\.svg|\.webp)$#i', $rank_image)) { $rank_image = ''; } diff --git a/phpBB/includes/functions_admin.php b/phpBB/includes/functions_admin.php index f9168ebb05..3164ed736c 100644 --- a/phpBB/includes/functions_admin.php +++ b/phpBB/includes/functions_admin.php @@ -479,7 +479,7 @@ function copy_forum_permissions($src_forum_id, $dest_forum_ids, $clear_dest_perm /** * Get physical file listing */ -function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png') +function filelist($rootdir, $dir = '', $type = 'gif|jpg|jpeg|png|svg|webp') { $matches = array($dir => array()); diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 111d24674f..850281c8c7 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -735,6 +735,10 @@ fieldset.polls dd div { margin-bottom: 10px; } +.profile-rank img { + max-width: 160px; +} + /* Post-profile avatars */ .postprofile .has-avatar .avatar-container { margin-bottom: 3px;