diff --git a/packages/block-library/src/image/deprecated.js b/packages/block-library/src/image/deprecated.js index 0365ddcfff5d1..8d1039696647a 100644 --- a/packages/block-library/src/image/deprecated.js +++ b/packages/block-library/src/image/deprecated.js @@ -651,6 +651,14 @@ const v6 = { }, }, }, + migrate( attributes ) { + const { height, width } = attributes; + return { + ...attributes, + width: typeof width === 'number' ? `${ width }px` : width, + height: typeof height === 'number' ? `${ height }px` : height, + }; + }, save( { attributes } ) { const { url, diff --git a/test/integration/fixtures/blocks/core__image__deprecated-v3-add-align-wrapper.json b/test/integration/fixtures/blocks/core__image__deprecated-v3-add-align-wrapper.json index bae213510011a..644f9629ea8d8 100644 --- a/test/integration/fixtures/blocks/core__image__deprecated-v3-add-align-wrapper.json +++ b/test/integration/fixtures/blocks/core__image__deprecated-v3-add-align-wrapper.json @@ -7,8 +7,8 @@ "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==", "alt": "", "caption": "", - "width": 100, - "height": 100 + "width": "100px", + "height": "100px" }, "innerBlocks": [] } diff --git a/test/integration/fixtures/blocks/core__image__deprecated-v3-add-align-wrapper.serialized.html b/test/integration/fixtures/blocks/core__image__deprecated-v3-add-align-wrapper.serialized.html index c03189e9b456c..2c0d6f487d57b 100644 --- a/test/integration/fixtures/blocks/core__image__deprecated-v3-add-align-wrapper.serialized.html +++ b/test/integration/fixtures/blocks/core__image__deprecated-v3-add-align-wrapper.serialized.html @@ -1,3 +1,3 @@ - +
diff --git a/test/integration/fixtures/blocks/core__image__deprecated-v6-add-style-width-height.json b/test/integration/fixtures/blocks/core__image__deprecated-v6-add-style-width-height.json index 7f83baa81fc63..1acdf6f92453c 100644 --- a/test/integration/fixtures/blocks/core__image__deprecated-v6-add-style-width-height.json +++ b/test/integration/fixtures/blocks/core__image__deprecated-v6-add-style-width-height.json @@ -7,8 +7,8 @@ "url": "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAACklEQVR4nGMAAQAABQABDQottAAAAABJRU5ErkJggg==", "alt": "", "caption": "", - "width": 164, - "height": 164, + "width": "164px", + "height": "164px", "sizeSlug": "large", "className": "is-style-rounded", "style": { diff --git a/test/integration/fixtures/blocks/core__image__deprecated-v6-add-style-width-height.serialized.html b/test/integration/fixtures/blocks/core__image__deprecated-v6-add-style-width-height.serialized.html index 57545968847e1..5ffd11a5baa8e 100644 --- a/test/integration/fixtures/blocks/core__image__deprecated-v6-add-style-width-height.serialized.html +++ b/test/integration/fixtures/blocks/core__image__deprecated-v6-add-style-width-height.serialized.html @@ -1,3 +1,3 @@ - +