Explorar el Código

use naturalWidth and naturalHeight first

Gildas hace 7 años
padre
commit
68d7786f9e
Se han modificado 1 ficheros con 4 adiciones y 2 borrados
  1. 4 2
      lib/single-file/util/doc-helper.js

+ 4 - 2
lib/single-file/util/doc-helper.js

@@ -335,12 +335,14 @@ this.docHelper = this.docHelper || (() => {
 		}
 		const width = imageElement.clientWidth;
 		const height = imageElement.clientHeight;
+		const pxWidth = imageElement.naturalWidth || (width - paddingLeft - paddingRight - borderLeft - borderRight);
+		const pxHeight = imageElement.naturalHeight || (height - paddingTop - paddingBottom - borderTop - borderBottom);
 		if (width >= 0 && height >= 0 && paddingLeft >= 0 && paddingRight >= 0 && paddingTop >= 0 && paddingBottom >= 0 && borderLeft >= 0 && borderRight >= 0 && borderTop >= 0 && borderBottom >= 0) {
 			return {
 				width: (paddingLeft || paddingRight || borderLeft || borderRight) && (width - paddingLeft - paddingRight - borderLeft - borderRight) + "px",
-				pxWidth: width - paddingLeft - paddingRight - borderLeft - borderRight,
+				pxWidth: pxWidth,
 				height: (paddingTop || paddingBottom || borderTop || borderBottom) && (height - paddingTop - paddingBottom - borderTop - borderBottom) + "px",
-				pxHeight: height - paddingTop - paddingBottom - borderTop - borderBottom,
+				pxHeight: pxHeight,
 			};
 		}
 	}