Do not use SVG width and height directly when embedding images

This commit is contained in:
Anna Dabrowska 2023-03-02 16:14:23 +01:00
parent e4a08effd6
commit 32cb5749b3

View file

@ -179,7 +179,12 @@ class SVG {
$h = hsc($xml['height'] ?? '100%');
$v = hsc($xml['viewBox']);
return "<svg width=\"$w\" height=\"$h\" viewBox=\"$v\"><path d=\"$def\" /></svg>";
// if viewbox is not defined, construct it from width and height, if available
if (empty($v) && !empty($w) && !empty($h)) {
$v = hsc("0 0 $w $h");
}
return "<svg viewBox=\"$v\"><path d=\"$def\" /></svg>";
}
/**