summaryrefslogtreecommitdiff
path: root/lib/images.js
blob: fdc36015cdc4a3e8ebf9b77fab09d72d508f4f99 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
var _ = require("underscore");

var promises = require("./promises");
var Html = require("./html");

exports.imgElement = function(func) {
    return function(element, messages) {
        return promises.when(func(element)).then(function(result) {
            var attributes = _.clone(result);
            if (element.altText) {
                attributes.alt = element.altText;
            }
            return [Html.selfClosingElement("img", attributes)];
        });
    };
};

// Undocumented, but retained for backwards-compatibility with 0.3.x
exports.inline = exports.imgElement;