diff options
| author | Michael Williamson <mike@zwobble.org> | 2021-11-01 19:08:28 +0000 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2021-11-01 19:08:28 +0000 |
| commit | e7803837d2a0214bc144f640bf3e2482c19ac35f (patch) | |
| tree | 034021c807fdbfb87b7445ebe787bc01a510ec17 /lib/docx | |
| parent | 47f27abda77e15faec56cd8e215d3156a36aca1d (diff) | |
Handle a:blip elements without image file
Diffstat (limited to 'lib/docx')
| -rw-r--r-- | lib/docx/body-reader.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/docx/body-reader.js b/lib/docx/body-reader.js index 0d04ccd..4bd38a9 100644 --- a/lib/docx/body-reader.js +++ b/lib/docx/body-reader.js @@ -462,7 +462,12 @@ function BodyReader(options) { function readBlip(element, blip) { var properties = element.first("wp:docPr").attributes; var altText = isBlank(properties.descr) ? properties.title : properties.descr; - return readImage(findBlipImageFile(blip), altText); + var blipImageFile = findBlipImageFile(blip); + if (blipImageFile === null) { + return emptyResultWithMessages([warning("Could not find image file for a:blip element")]); + } else { + return readImage(blipImageFile, altText); + } } function isBlank(value) { @@ -474,12 +479,14 @@ function BodyReader(options) { var linkRelationshipId = blip.attributes["r:link"]; if (embedRelationshipId) { return findEmbeddedImageFile(embedRelationshipId); - } else { + } else if (linkRelationshipId) { var imagePath = relationships.findTargetByRelationshipId(linkRelationshipId); return { path: imagePath, read: files.read.bind(files, imagePath) }; + } else { + return null; } } |
