From afbf7aadd2db8756c8c003dfafd94862563869c8 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Thu, 21 Oct 2021 21:47:14 +0200 Subject: [PATCH 1/8] [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; From 6218c2e1209e52ba7c9cc3eb6a01ce9b2bcb4f3f Mon Sep 17 00:00:00 2001 From: 3D-I Date: Thu, 21 Oct 2021 22:05:25 +0200 Subject: [PATCH 2/8] [ticket/16899] Add SVG and WEBP to ranks, smilies and topic icons PHPBB3-16899 --- phpBB/includes/acp/acp_icons.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index b1d4d2a27a..2220089231 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -116,8 +116,8 @@ class acp_icons $_images[$path . $img]['file'] = $path . $img; - $_images[$path . $img]['width'] = $img_size ? $img_size[0] : ''; - $_images[$path . $img]['height'] = $img_size ? $img_size[1] : ''; + $_images[$path . $img]['width'] = $img_size ? $img_size[0] : 127; + $_images[$path . $img]['height'] = $img_size ? $img_size[1] : 127; } } unset($imglist); From 40322bb1b6278f9e907d6116b03fa8ad1f0d7bc3 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Thu, 21 Oct 2021 23:44:08 +0200 Subject: [PATCH 3/8] [ticket/16899] Add SVG and WEBP to ranks, smilies and topic icons PHPBB3-16899 --- phpBB/styles/prosilver/theme/content.css | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 850281c8c7..265f336ee0 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -737,6 +737,7 @@ fieldset.polls dd div { .profile-rank img { max-width: 160px; + image-rendering: crisp-edges; } /* Post-profile avatars */ From 06ef03f8d657e9e2cfab2c2f5c0db02e39e75d1c Mon Sep 17 00:00:00 2001 From: 3D-I Date: Thu, 21 Oct 2021 23:54:04 +0200 Subject: [PATCH 4/8] [ticket/16899] Add SVG and WEBP to ranks, smilies and topic icons Take care of the old crappy IE PHPBB3-16899 --- phpBB/styles/prosilver/theme/content.css | 1 + 1 file changed, 1 insertion(+) diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 265f336ee0..6a92cf2122 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -738,6 +738,7 @@ fieldset.polls dd div { .profile-rank img { max-width: 160px; image-rendering: crisp-edges; + -ms-interpolation-mode: nearest-neighbor; } /* Post-profile avatars */ From 7472d300b62894851ee56b94487467761ce8bb52 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 22 Oct 2021 02:29:45 +0200 Subject: [PATCH 5/8] [ticket/16899] Add SVG and WEBP to ranks, smilies and topic icons Attempt to read the SVG dimensions PHPBB3-16899 --- phpBB/includes/acp/acp_icons.php | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 2220089231..7f10c73c37 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -113,11 +113,21 @@ class acp_icons } } } + else + // getimagesize can't read the dimensions of the SVG files + // https://bugs.php.net/bug.php?id=71517 + { + $xml_get = simplexml_load_file($phpbb_root_path . $img_path . '/' . $path . $img); + + $svg_width = intval($xml_get['width']); + $svg_height = intval($xml_get['height']); + } $_images[$path . $img]['file'] = $path . $img; - $_images[$path . $img]['width'] = $img_size ? $img_size[0] : 127; - $_images[$path . $img]['height'] = $img_size ? $img_size[1] : 127; + // Give SVG a fallback on failure + $_images[$path . $img]['width'] = $img_size ? $img_size[0] : ($svg_width ?: 32); + $_images[$path . $img]['height'] = $img_size ? $img_size[1] : ($svg_height ?: 32); } } unset($imglist); From f841a0a1b85771b48b041ebf6cd732e58ff8e0a9 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 22 Oct 2021 02:34:35 +0200 Subject: [PATCH 6/8] [ticket/16899] Add SVG and WEBP to ranks, smilies and topic icons Attempt to read the SVG dimensions PHPBB3-16899 --- phpBB/includes/acp/acp_icons.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/phpBB/includes/acp/acp_icons.php b/phpBB/includes/acp/acp_icons.php index 7f10c73c37..4758e89a93 100644 --- a/phpBB/includes/acp/acp_icons.php +++ b/phpBB/includes/acp/acp_icons.php @@ -114,12 +114,12 @@ class acp_icons } } else - // getimagesize can't read the dimensions of the SVG files - // https://bugs.php.net/bug.php?id=71517 { + // getimagesize can't read the dimensions of the SVG files + // https://bugs.php.net/bug.php?id=71517 $xml_get = simplexml_load_file($phpbb_root_path . $img_path . '/' . $path . $img); - $svg_width = intval($xml_get['width']); + $svg_width = intval($xml_get['width']); $svg_height = intval($xml_get['height']); } From d17b15a54520e68a1fd8cd57e187a7262db40a2d Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 22 Oct 2021 16:14:18 +0200 Subject: [PATCH 7/8] [ticket/16899] Add SVG and WEBP to ranks, smilies and topic icons PHPBB3-16899 --- phpBB/styles/prosilver/theme/content.css | 2 -- 1 file changed, 2 deletions(-) diff --git a/phpBB/styles/prosilver/theme/content.css b/phpBB/styles/prosilver/theme/content.css index 6a92cf2122..850281c8c7 100644 --- a/phpBB/styles/prosilver/theme/content.css +++ b/phpBB/styles/prosilver/theme/content.css @@ -737,8 +737,6 @@ fieldset.polls dd div { .profile-rank img { max-width: 160px; - image-rendering: crisp-edges; - -ms-interpolation-mode: nearest-neighbor; } /* Post-profile avatars */ From 9671a0021401b402894d60e2335b939f8131c31b Mon Sep 17 00:00:00 2001 From: 3D-I Date: Sun, 24 Oct 2021 19:52:01 +0200 Subject: [PATCH 8/8] [ticket/16899] Add SVG and WEBP to ranks, smilies and topic icons Prevent breaking layout PHPBB3-16899 --- phpBB/adm/style/acp_icons.html | 2 +- phpBB/adm/style/acp_ranks.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/phpBB/adm/style/acp_icons.html b/phpBB/adm/style/acp_icons.html index 45fe7f8ebc..25d5cb5207 100644 --- a/phpBB/adm/style/acp_icons.html +++ b/phpBB/adm/style/acp_icons.html @@ -105,7 +105,7 @@ - {items.TEXT_ALT} + {items.TEXT_ALT} [{items.IMG}] diff --git a/phpBB/adm/style/acp_ranks.html b/phpBB/adm/style/acp_ranks.html index d373657114..aac5de6fe7 100644 --- a/phpBB/adm/style/acp_ranks.html +++ b/phpBB/adm/style/acp_ranks.html @@ -85,7 +85,7 @@ - {ranks.RANK_TITLE}  -   + {ranks.RANK_TITLE}  -   {ranks.RANK_TITLE}   -  {ranks.MIN_POSTS}