1
0
mirror of https://github.com/processwire/processwire.git synced 2025-08-10 08:44:46 +02:00

Add faster width/height detection for SVG images in Pageimage class

This commit is contained in:
Toutouwai
2023-09-22 09:54:33 -04:00
committed by Ryan Cramer
parent 21e370b7ee
commit a0fabd6811

View File

@@ -547,6 +547,13 @@ class Pageimage extends Pagefile {
$a = @simplexml_load_string($xml)->attributes(); $a = @simplexml_load_string($xml)->attributes();
if((int) $a->width > 0) $width = (int) $a->width; if((int) $a->width > 0) $width = (int) $a->width;
if((int) $a->height > 0) $height = (int) $a->height; 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'))) { if((!$width || !$height) && (extension_loaded('imagick') || class_exists('\IMagick'))) {
@@ -1873,4 +1880,3 @@ class Pageimage extends Pagefile {
} }
} }