aboutsummaryrefslogtreecommitdiff
path: root/lib/docx/document-xml-reader.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/docx/document-xml-reader.js')
-rw-r--r--lib/docx/document-xml-reader.js39
1 files changed, 25 insertions, 14 deletions
diff --git a/lib/docx/document-xml-reader.js b/lib/docx/document-xml-reader.js
index 12016b0..e290792 100644
--- a/lib/docx/document-xml-reader.js
+++ b/lib/docx/document-xml-reader.js
@@ -215,23 +215,34 @@ function DocumentXmlReader(options) {
.getElementsByTagName("pic:blipFill")
.getElementsByTagName("a:blip");
- var results = blips.map(function(blip) {
- var relationshipId = blip.attributes["r:embed"];
- var imagePath = joinZipPath("word", relationships[relationshipId].target);
- var readImage = docxFile.read.bind(docxFile, imagePath);
- var altText = element.first("wp:docPr").attributes.descr;
-
- var image = documents.Image({
- readImage: readImage,
- altText: altText,
- contentType: contentTypes.findContentType(imagePath)
- });
- return new Result(image);
- });
+ return Result.combine(blips.map(readBlip.bind(null, element)));
+ }
+
+ function readBlip(element, blip) {
+ var relationshipId = blip.attributes["r:embed"];
+ var imagePath = joinZipPath("word", relationships[relationshipId].target);
+ var readImage = docxFile.read.bind(docxFile, imagePath);
+ var altText = element.first("wp:docPr").attributes.descr;
+ var contentType = contentTypes.findContentType(imagePath);
- return Result.combine(results);
+ var image = documents.Image({
+ readImage: readImage,
+ altText: altText,
+ contentType: contentType
+ });
+ var warnings = supportedImageTypes[contentType] ?
+ [] : warning("Image of type " + contentType + " is unlikely to display in web browsers");
+ return new Result(image, warnings);
}
}
+
+var supportedImageTypes = {
+ "image/png": true,
+ "image/gif": true,
+ "image/jpeg": true,
+ "image/svg+xml": true,
+ "image/tiff": true
+};
var ignoreElements = {
"w:bookmarkStart": true,