diff --git a/lib/magicPenMedia.js b/lib/magicPenMedia.js index 4db5dfe..dba2470 100644 --- a/lib/magicPenMedia.js +++ b/lib/magicPenMedia.js @@ -24,6 +24,7 @@ module.exports = { var width = options.width || 0; var height = options.height || 0; var alt = options.alt; + var title = options.title; this.alt({ html: { @@ -51,6 +52,9 @@ module.exports = { if (typeof alt !== 'undefined') { attributes.push('alt="' + entitify(String(alt)) + '"'); } + if (typeof title !== 'undefined') { + attributes.push('title="' + entitify(String(title)) + '"'); + } var styleProperties = []; if (width) { diff --git a/test/magicPenMedia.js b/test/magicPenMedia.js index 47ce83f..620420c 100644 --- a/test/magicPenMedia.js +++ b/test/magicPenMedia.js @@ -36,6 +36,16 @@ describe('magicpen-media', function () { ); }); + it('should support a title passed in the options object', function () { + expect( + magicPen.clone('html').media('foobar.jpg', { title: 'hey"there' }).toString(), + 'to equal', + '