mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-25 03:44:29 +03:00
Fixed mobiledoc.populateImageSizes
handling of empty image card payloads
no issue - it's possible that image cards can be saved when they have no `src` attribute (placeholders)
This commit is contained in:
parent
996b30d335
commit
2553da1bee
@ -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;
|
||||
}
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user