diff options
| author | Michael Williamson <mike@zwobble.org> | 2014-07-08 10:20:52 +0100 |
|---|---|---|
| committer | Michael Williamson <mike@zwobble.org> | 2014-07-08 10:20:52 +0100 |
| commit | 40fc65d1f2874eb707a4fb4e93c4a66ccd59f850 (patch) | |
| tree | 74fe9a043438e80843ee95e3dafc8e52adc9b950 /lib/images.js | |
| parent | d54de16a5c570bb6f4aaf3af0c8f0a2fa4987880 (diff) | |
Extract common code for image conversion
Diffstat (limited to 'lib/images.js')
| -rw-r--r-- | lib/images.js | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/images.js b/lib/images.js new file mode 100644 index 0000000..613a264 --- /dev/null +++ b/lib/images.js @@ -0,0 +1,14 @@ +var promises = require("./promises"); +var htmlPaths = require("./html-paths"); + +exports.inline = function(func) { + return function(element, html, messages, callback) { + return promises.when(func(element)).then(function(result) { + var attributes = {src: result.src}; + if (element.altText) { + attributes.alt = element.altText; + } + html.selfClosing(htmlPaths.element("img", attributes)); + }).then(callback, callback); + }; +}; |
