diff --git a/svg.php b/svg.php index abcf427..6688fc8 100644 --- a/svg.php +++ b/svg.php @@ -175,11 +175,16 @@ class SVG { $xml = simplexml_load_file($file, SvgNode::class); $def = hsc((string) $xml->path['d']); - $w = hsc($xml['width']); - $h = hsc($xml['height']); + $w = hsc($xml['width'] ?? '100%'); + $h = hsc($xml['height'] ?? '100%'); $v = hsc($xml['viewBox']); - return ""; + // 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 ""; } /**