diff --git a/core/server/lib/mobiledoc/cards/image.js b/core/server/lib/mobiledoc/cards/image.js index e8c3ecf5ee..316411f0ae 100644 --- a/core/server/lib/mobiledoc/cards/image.js +++ b/core/server/lib/mobiledoc/cards/image.js @@ -23,6 +23,9 @@ module.exports = { if (payload.alt) { img.setAttribute('alt', payload.alt); } + if (payload.title) { + img.setAttribute('title', payload.title); + } figure.appendChild(img); diff --git a/core/test/unit/lib/mobiledoc/cards/image_spec.js b/core/test/unit/lib/mobiledoc/cards/image_spec.js index 627db0b3a0..3b9d08ba93 100644 --- a/core/test/unit/lib/mobiledoc/cards/image_spec.js +++ b/core/test/unit/lib/mobiledoc/cards/image_spec.js @@ -45,6 +45,20 @@ describe('Image card', function () { serializer.serialize(card.render(opts)).should.eql('
example image
'); }); + it('renders an image with title attribute', function () { + let opts = { + env: { + dom: new SimpleDom.Document() + }, + payload: { + src: 'https://www.ghost.org/image.png', + title: 'example image' + } + }; + + serializer.serialize(card.render(opts)).should.eql('
'); + }); + it('renders nothing with no src', function () { let opts = { env: {