Browse Source

better handling of missing/invalid images

Gildas 7 years ago
parent
commit
4ae2053c17
1 changed files with 2 additions and 3 deletions
  1. 2 3
      lib/single-file/single-file-core.js

+ 2 - 3
lib/single-file/single-file-core.js

@@ -1072,6 +1072,7 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 				let resourceURL = resourceElement.getAttribute(attributeName);
 				if (resourceURL) {
 					resourceURL = DomUtil.normalizeURL(resourceURL);
+					resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
 					if (resourceURL && resourceURL != baseURI && DomUtil.testValidPath(resourceURL)) {
 						try {
 							const { content, indexResource, duplicate } = await batchRequest.addURL(new URL(resourceURL, baseURI).href);
@@ -1084,12 +1085,10 @@ this.SingleFileCore = this.SingleFileCore || (() => {
 									} else {
 										resourceElement.setAttribute(attributeName, content);
 									}
-								} else {
-									resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
 								}
 							}
 						} catch (error) {
-							resourceElement.setAttribute(attributeName, EMPTY_IMAGE);
+							/* ignored */
 						}
 					}
 				}