From 40fc65d1f2874eb707a4fb4e93c4a66ccd59f850 Mon Sep 17 00:00:00 2001 From: Michael Williamson Date: Tue, 8 Jul 2014 10:20:52 +0100 Subject: Extract common code for image conversion --- lib/images.js | 14 ++++++++++++++ 1 file changed, 14 insertions(+) create mode 100644 lib/images.js (limited to 'lib/images.js') 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); + }; +}; -- cgit v1.2.3