You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

31 lines
861 B

var _ = require("underscore");
var promises = require("./promises");
var Html = require("./html");
exports.imgElement = imgElement;
function imgElement(func) {
return function(element, messages) {
return promises.when(func(element)).then(function(result) {
var attributes = {};
if (element.altText) {
attributes.alt = element.altText;
}
_.extend(attributes, result);
return [Html.freshElement("img", attributes)];
});
};
}
// Undocumented, but retained for backwards-compatibility with 0.3.x
exports.inline = exports.imgElement;
exports.dataUri = imgElement(function(element) {
return element.read("base64").then(function(imageBuffer) {
return {
src: "data:" + element.contentType + ";base64," + imageBuffer
};
});
});