From a0fabd68111c3c19f09b112eb66c7cc29dd65746 Mon Sep 17 00:00:00 2001 From: Toutouwai Date: Fri, 22 Sep 2023 09:54:33 -0400 Subject: [PATCH] Add faster width/height detection for SVG images in Pageimage class --- wire/core/Pageimage.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/wire/core/Pageimage.php b/wire/core/Pageimage.php index 75f68b32..4dcdf5bd 100644 --- a/wire/core/Pageimage.php +++ b/wire/core/Pageimage.php @@ -547,6 +547,13 @@ class Pageimage extends Pagefile { $a = @simplexml_load_string($xml)->attributes(); if((int) $a->width > 0) $width = (int) $a->width; if((int) $a->height > 0) $height = (int) $a->height; + if((!$width || !$height) && $a->viewBox) { + $values = explode(' ', $a->viewBox); + if(count($values) === 4) { + $width = (int) round($values[2]); + $height = (int) round($values[3]); + } + } } if((!$width || !$height) && (extension_loaded('imagick') || class_exists('\IMagick'))) { @@ -1873,4 +1880,3 @@ class Pageimage extends Pagefile { } } -