Use the size of the outermost svg element
... in case there are nested svg elements.
This commit is contained in:
parent
35d2f8682c
commit
17f71094f2
@ -101,6 +101,9 @@ class MiniSVGParser {
|
|||||||
/** @var int */
|
/** @var int */
|
||||||
public $height=0;
|
public $height=0;
|
||||||
|
|
||||||
|
/** @var int */
|
||||||
|
private $xml_depth=0;
|
||||||
|
|
||||||
/** @param string $file */
|
/** @param string $file */
|
||||||
function __construct($file) {
|
function __construct($file) {
|
||||||
$xml_parser = xml_parser_create();
|
$xml_parser = xml_parser_create();
|
||||||
@ -110,13 +113,15 @@ class MiniSVGParser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function startElement($parser, $name, $attrs) {
|
function startElement($parser, $name, $attrs) {
|
||||||
if($name == "SVG") {
|
if($name == "SVG" && $this->xml_depth == 0) {
|
||||||
$this->width = int_escape($attrs["WIDTH"]);
|
$this->width = int_escape($attrs["WIDTH"]);
|
||||||
$this->height = int_escape($attrs["HEIGHT"]);
|
$this->height = int_escape($attrs["HEIGHT"]);
|
||||||
}
|
}
|
||||||
|
$this->xml_depth++;
|
||||||
}
|
}
|
||||||
|
|
||||||
function endElement($parser, $name) {
|
function endElement($parser, $name) {
|
||||||
|
$this->xml_depth--;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user