:octocat: +QROptionsTrait::$svgAddXmlHeader

This commit is contained in:
smiley
2023-07-09 15:52:03 +02:00
parent 3d894ad16a
commit cdaf8aac66
2 changed files with 14 additions and 2 deletions
+7 -2
View File
@@ -77,8 +77,7 @@ class QRMarkupSVG extends QRMarkup{
$height = ($this->options->svgHeight !== null) ? sprintf(' height="%s"', $this->options->svgHeight) : '';
/** @noinspection HtmlUnknownAttribute */
return sprintf(
'<?xml version="1.0" encoding="UTF-8"?>%6$s'.
$header = sprintf(
'<svg xmlns="http://www.w3.org/2000/svg" class="qr-svg %1$s" viewBox="0 0 %2$s %2$s" preserveAspectRatio="%3$s"%4$s%5$s>%6$s',
$this->options->cssClass,
($this->options->svgViewBoxSize ?? $this->moduleCount),
@@ -87,6 +86,12 @@ class QRMarkupSVG extends QRMarkup{
$height,
$this->options->eol
);
if($this->options->svgAddXmlHeader){
$header = sprintf('<?xml version="1.0" encoding="UTF-8"?>%s%s', $this->options->eol, $header);
}
return $header;
}
/**
+7
View File
@@ -315,6 +315,13 @@ trait QROptionsTrait{
* QRMarkupSVG settings
*/
/**
* Whether to add an XML header line or not, e.g. to embed the SVG directly in HTML
*
* `<?xml version="1.0" encoding="UTF-8"?>`
*/
protected bool $svgAddXmlHeader = true;
/**
* SVG opacity
*/