From 7472d300b62894851ee56b94487467761ce8bb52 Mon Sep 17 00:00:00 2001 From: 3D-I Date: Fri, 22 Oct 2021 02:29:45 +0200 Subject: [PATCH] [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);