File tree Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Expand file tree Collapse file tree 1 file changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -36,8 +36,10 @@ class SvgToPng {
36
36
if ( svgs . length > 0 ) {
37
37
svgs . forEach ( svg => {
38
38
const canvas = document . createElement ( 'canvas' ) ;
39
- const svgWidth = svg . width ? svg . width . baseVal . value : svg . getAttribute ( "width" )
40
- const svgHeight = svg . height ? svg . height . baseVal . value : svg . getAttribute ( "Height" )
39
+ const svgWidth = svg . width ? svg . width . baseVal . value : svg . getAttribute ( "width" ) ;
40
+ const svgHeight = svg . height ? svg . height . baseVal . value : svg . getAttribute ( "height" ) ;
41
+ const svgDisplay = window . getComputedStyle ( svg , null ) . display ;
42
+ const svgVerticalAlign = window . getComputedStyle ( svg , null ) . verticalAlign ;
41
43
canvas . width = parseFloat ( svgWidth ) * 1.5 ;
42
44
canvas . height = parseFloat ( svgHeight ) * 1.5 ;
43
45
const img = new Image ( ) ;
@@ -49,6 +51,8 @@ class SvgToPng {
49
51
newImg . src = pngDataUrl ;
50
52
newImg . width = svgWidth ;
51
53
newImg . height = svgHeight ;
54
+ newImg . style . display = svgDisplay ? svgDisplay : "inline-block" ;
55
+ newImg . style . verticalAlign = svgVerticalAlign ? svgVerticalAlign : "middle" ;
52
56
if ( svg . parentNode )
53
57
svg . parentNode . replaceChild ( newImg , svg ) ;
54
58
} ;
You can’t perform that action at this time.
0 commit comments