Do not use SVG width and height directly when embedding images
This commit is contained in:
parent
e4a08effd6
commit
32cb5749b3
1 changed files with 6 additions and 1 deletions
7
svg.php
7
svg.php
|
@ -179,7 +179,12 @@ class SVG {
|
||||||
$h = hsc($xml['height'] ?? '100%');
|
$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>";
|
// 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>";
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue