diff options
| author | Michael Williamson <mike@zwobble.org> | 2013-04-27 22:39:03 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2013-04-27 22:39:03 +0100 |
| commit | 8a3d7bf7bd7c960a29afee293ef7b6a5011fe834 (patch) | |
| tree | 0bca5f331c4dda11252f92fc50a2f115da098710 | |
| parent | 2642cdd90f25528df0d9501200bc95417e60ec82 (diff) | |
Use content type from element when generating HTML
| -rw-r--r-- | lib/document-to-html.js | 2 | ||||
| -rw-r--r-- | tests/document-to-html.tests.js | 3 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/document-to-html.js b/lib/document-to-html.js index e02ca6f..25892d5 100644 --- a/lib/document-to-html.js +++ b/lib/document-to-html.js @@ -104,7 +104,7 @@ function DocumentConverter(options) { }, "image": function(element, html, messages, callback) { element.read("base64").then(function(imageBuffer) { - var src = "data:image/png;base64," + imageBuffer; + var src = "data:" + element.contentType + ";base64," + imageBuffer; var attributes = {src: src}; if (element.altText) { attributes.alt = element.altText; diff --git a/tests/document-to-html.tests.js b/tests/document-to-html.tests.js index 864e3ee..c7b7bcf 100644 --- a/tests/document-to-html.tests.js +++ b/tests/document-to-html.tests.js @@ -179,7 +179,8 @@ describe('DocumentConverter', function() { var image = new documents.Image({ readImage: function(encoding) { return q.when(imageBuffer.toString(encoding)); - } + }, + contentType: "image/png" }); var converter = new DocumentConverter(); return converter.convertToHtml(image).then(function(result) { |
