If SVG width and height are not define, set them to 100%

This commit is contained in:
Anna Dabrowska 2023-03-02 13:31:26 +01:00
commit e4a08effd6

View file

@ -175,8 +175,8 @@ class SVG {
$xml = simplexml_load_file($file, SvgNode::class); $xml = simplexml_load_file($file, SvgNode::class);
$def = hsc((string) $xml->path['d']); $def = hsc((string) $xml->path['d']);
$w = hsc($xml['width']); $w = hsc($xml['width'] ?? '100%');
$h = hsc($xml['height']); $h = hsc($xml['height'] ?? '100%');
$v = hsc($xml['viewBox']); $v = hsc($xml['viewBox']);
return "<svg width=\"$w\" height=\"$h\" viewBox=\"$v\"><path d=\"$def\" /></svg>"; return "<svg width=\"$w\" height=\"$h\" viewBox=\"$v\"><path d=\"$def\" /></svg>";