Skip to content

Commit

Permalink
Support a title passed in the options object.
Browse files Browse the repository at this point in the history
papandreou committed Jul 6, 2015
1 parent 645403c commit b35623a
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/magicPenMedia.js
Original file line number Diff line number Diff line change
@@ -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) {
10 changes: 10 additions & 0 deletions test/magicPenMedia.js
Original file line number Diff line number Diff line change
@@ -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',
'<div style="font-family: monospace; white-space: nowrap">\n' +
' <div><img src="foobar.jpg" title="hey&quot;there"></div>\n' +
'</div>'
);
});

it('should render an image given as a data: url', function () {
expect(
magicPen.clone('html').media('data:image/jpg,base64;Zm9v').toString(),

0 comments on commit b35623a

Please sign in to comment.