diff --git a/core/server/lib/mobiledoc.js b/core/server/lib/mobiledoc.js index 237a2360e1..e232ad4ae8 100644 --- a/core/server/lib/mobiledoc.js +++ b/core/server/lib/mobiledoc.js @@ -134,7 +134,7 @@ module.exports = { const sizePromises = mobiledoc.cards.map(async (card) => { const [cardName, payload] = card; - const needsFilling = cardName === 'image' && (!payload.width || !payload.height); + const needsFilling = cardName === 'image' && payload && payload.src && (!payload.width || !payload.height); if (!needsFilling) { return; } diff --git a/test/unit/lib/mobiledoc_spec.js b/test/unit/lib/mobiledoc_spec.js index 6b15780c26..782d5397fb 100644 --- a/test/unit/lib/mobiledoc_spec.js +++ b/test/unit/lib/mobiledoc_spec.js @@ -127,12 +127,13 @@ describe('lib/mobiledoc', function () { storage.getStorage().storagePath = originalStoragePath; }); - it('works', async function () { + it.only('works', async function () { let mobiledoc = { cards: [ ['image', {src: '/content/images/ghost-logo.png'}], ['image', {src: 'http://example.com/external.jpg'}], - ['image', {src: 'https://images.unsplash.com/favicon_too_large?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=2000&fit=max&ixid=eyJhcHBfaWQiOjExNzczfQ'}] + ['image', {src: 'https://images.unsplash.com/favicon_too_large?ixlib=rb-1.2.1&q=80&fm=jpg&crop=entropy&cs=tinysrgb&w=2000&fit=max&ixid=eyJhcHBfaWQiOjExNzczfQ'}], + ['image', {}] ] }; @@ -148,7 +149,7 @@ describe('lib/mobiledoc', function () { unsplashMock.isDone().should.be.true(); - transformed.cards.length.should.equal(3); + transformed.cards.length.should.equal(4); should.exist(transformed.cards[0][1].width); transformed.cards[0][1].width.should.equal(800);