diff --git a/packages/block-library/src/image/deprecated.js b/packages/block-library/src/image/deprecated.js index 0365ddcfff5d17..8d1039696647a3 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 bae213510011ac..644f9629ea8d86 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 c03189e9b456c0..2c0d6f487d57b1 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 7f83baa81fc635..1acdf6f92453c8 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 57545968847e1b..5ffd11a5baa8e7 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 @@ - +