diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-02 23:17:11 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-02 23:17:11 +0100 |
| commit | b346be31b8103d403134f12141b51f3321a6f442 (patch) | |
| tree | 67ebdb18b570756eb76c2c8d221317747b8286d1 /lib | |
| parent | cf81751b61fac1042623839d902ae31124d1f5fc (diff) | |
Write altText of image if available
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/document-to-html.js | 6 | ||||
| -rw-r--r-- | lib/documents.js | 5 |
2 files changed, 8 insertions, 3 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js index 9951cbb..a1b2ec6 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -89,7 +89,11 @@ function DocumentConverter(options) { return element.read().then(function(imageBuffer) { // TODO: set alt attribute to wp:inline/wp:docPr/@descr var src = "data:image/png;base64," + imageBuffer.toString("base64"); - html.selfClosing(styles.element("img", {"src": src})) + var attributes = {src: src}; + if (element.altText) { + attributes.alt = element.altText; + } + html.selfClosing(styles.element("img", attributes)); }); } }; diff --git a/lib/documents.js b/lib/documents.js index b28281f..d1c1e03 100644 --- a/lib/documents.js +++ b/lib/documents.js @@ -33,10 +33,11 @@ function ElementWithChildren(type) { }; } -function Image(read) { +function Image(read, altText) { return { type: "image", - read: read + read: read, + altText: altText }; } |
