Add width and height to SVG image
Beginning from Mathoid 0.2.5 the specification of a height and width attribute of the image will be required. This patch gets those information from the SVG and copies them to the img tag. See also Bug: 20202 Bug: 68295 Change-Id: I93e26a9f538acf21aea1501144bb1dd886ae0410
This commit is contained in:
parent
130c3f44f1
commit
77069f6e5f
|
@ -348,6 +348,15 @@ class MathMathML extends MathRenderer {
|
||||||
$style = preg_replace( '/margin\-(left|right)\:\s*\d+(\%|in|cm|mm|em|ex|pt|pc|px)\;/', '', $style );
|
$style = preg_replace( '/margin\-(left|right)\:\s*\d+(\%|in|cm|mm|em|ex|pt|pc|px)\;/', '', $style );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// TODO: Figure out if there is a way to construct
|
||||||
|
// a SVGReader from a string that represents the SVG
|
||||||
|
// content
|
||||||
|
if ( preg_match( "/height=\"(.*?)\"/" , $this->getSvg(), $matches ) ) {
|
||||||
|
$style .= "height: " . $matches[1] . "; ";
|
||||||
|
}
|
||||||
|
if ( preg_match( "/width=\"(.*?)\"/", $this->getSvg(), $matches ) ) {
|
||||||
|
$style .= "width: " . $matches[1] . ";";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -364,6 +373,7 @@ class MathMathML extends MathRenderer {
|
||||||
} else {
|
} else {
|
||||||
$png = false;
|
$png = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
$attribs = array();
|
$attribs = array();
|
||||||
if ( $classOverride === false ) { // $class = '' suppresses class attribute
|
if ( $classOverride === false ) { // $class = '' suppresses class attribute
|
||||||
$class = $this->getClassName( true, $png );
|
$class = $this->getClassName( true, $png );
|
||||||
|
@ -372,6 +382,7 @@ class MathMathML extends MathRenderer {
|
||||||
$class = $classOverride;
|
$class = $classOverride;
|
||||||
$style = '';
|
$style = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !$png ) {
|
if ( !$png ) {
|
||||||
$this->correctSvgStyle( $this->getSvg(), $style );
|
$this->correctSvgStyle( $this->getSvg(), $style );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue