Skip to content

Image: Add transform block support - #86955

Draft
aaronrobertshaw wants to merge 3 commits into
add/transform-scalefrom
add/image-transform-support
Draft

aaronrobertshaw wants to merge 3 commits into
add/transform-scalefrom
add/image-transform-support

Conversation

@aaronrobertshaw

@aaronrobertshaw aaronrobertshaw commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Important

Stacked on #86727. Merge #86240, #86282 and #86727 first.

Related:

What?

Image blocks can now be rotated, offset and scaled. The transform applies to the image, so the caption stays put.

Why?

The transform support styles the block wrapper. For Image, that is the figure, so the caption would turn with the picture.

How?

Image follows its existing Border and Shadow pattern:

  • Support: rotate, translate and scale, with __experimentalSkipSerialization.
  • Image: save.jsx and image.jsx add getTransformClassesAndStyles() to the img style.
  • Resize box: gets the same inline transform, so the handles turn with the image.
  • Global Styles: selectors.transform targets the img and the editor resize box.
  • Lightbox: zooms from the transformed image's centre and scale. The enlarged image is not transformed.

No deprecation is needed: Image never shipped with this support.

Note

The block outline stays square while the image turns. Dragging a handle on a rotated image is fixed in #86884.

Testing Instructions

Use a theme with appearanceTools, such as Twenty Twenty-Five.

Block values

  1. Add an Image with a caption and "Enlarge on click".
  2. Set a rotation, an offset and a scale.
  3. Check the image and its resize handles transform, and the caption does not.
  4. On the front end, check the same, then open the lightbox. The enlarged image is not transformed.

Global Styles

  1. In Styles > Blocks > Image, set a rotation.
  2. Check a new Image turns in the editor, with its handles, and on the front end.

Screenshots or screencast

86955-image-transform.mp4

Use of AI Tools

Written with Claude Code, then reviewed and tested by hand.

@aaronrobertshaw aaronrobertshaw added [Type] Enhancement A suggestion for improvement. [Block] Image Affects the Image Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi labels Nov 17, 2026
@aaronrobertshaw aaronrobertshaw self-assigned this Nov 17, 2026
@aaronrobertshaw aaronrobertshaw added the [Package] Block library /packages/block-library label Nov 17, 2026
@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

Preview in WordPress Playground Preview in Storybook

📦 Bundle size

Size Change: +410 B (0%)

Total Size: 8.67 MB

📦 View Changed
Filename Size Change
build/modules/block-library/image/view.min.js 3.58 kB +136 B (+3.95%)
build/scripts/block-library/index.min.js 427 kB +75 B (+0.02%)
build/styles/block-library/image/style-rtl.css 3.03 kB +30 B (+1%)
build/styles/block-library/image/style-rtl.min.css 1.97 kB +26 B (+1.34%)
build/styles/block-library/image/style.css 3.04 kB +30 B (+1%)
build/styles/block-library/image/style.min.css 1.97 kB +29 B (+1.5%)
build/styles/block-library/style-rtl.css 22.9 kB +23 B (+0.1%)
build/styles/block-library/style-rtl.min.css 19.5 kB +19 B (+0.1%)
build/styles/block-library/style.css 23.1 kB +23 B (+0.1%)
build/styles/block-library/style.min.css 19.5 kB +19 B (+0.1%)

b23972e Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 4a97733 add/transform-scale % Change
timeToFirstByte 35.4 ms +7.34% -4.1% 35.3 ms +13.17% -4.39% 0.28%
largestContentfulPaint 60 ms +6.67% -6.67% 60 ms +6.67% -6.67% 0%
lcpMinusTtfb 23.8 ms +12.39% -9.24% 22.4 ms +9.82% -9.82% 6.25%
wpBeforeTemplate 18.28 ms +13.13% -3.39% 18.1 ms +15.97% -2.32% 0.99%
wpTemplate 13.72 ms +3.94% -6.2% 13.92 ms +5.96% -5.53% -1.44%
wpTotal 32.39 ms +7.63% -4.32% 32.22 ms +13.87% -4.5% 0.53%
wpMemoryUsage 7.75 MB +0% -0% 7.73 MB +0% -0% 0.24%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 4a97733 add/transform-scale % Change
timeToFirstByte 30.75 ms +4.55% -2.44% 30.15 ms +8.62% -4.64% 1.99%
largestContentfulPaint 56 ms +10.71% -0% 56 ms +0% -7.14% 0%
lcpMinusTtfb 26.55 ms +9.6% -4.71% 24.05 ms +10.19% -2.7% 10.4%
wpBeforeTemplate 16.65 ms +11.77% -2.16% 16.79 ms +2.8% -5.66% -0.83%
wpTemplate 10.84 ms +5.81% -4.61% 10.69 ms +4.96% -3.84% 1.4%
wpTotal 27.91 ms +5.05% -2.29% 27.48 ms +8.92% -4% 1.56%
wpMemoryUsage 6.44 MB +0% -0% 6.42 MB +0% -0% 0.28%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 4a97733 add/transform-scale % Change
mediaProcessingJpeg 217.6 ms +1.77% -0.97% 219.33 ms +2.53% -1.49% -0.79%
mediaProcessingAvif 3584.83 ms +0.36% -0.44% 3580.43 ms +0.38% -0.94% 0.12%
mediaProcessingJpegToAvif 2479.4 ms +1.25% -0.52% 2487.79 ms +1.41% -1% -0.34%

media-upload

Metric 4a97733 add/transform-scale % Change
jpegUploadProcessing 1437.29 ms +1.19% -1.28% 1438.83 ms +2.31% -1.83% -0.11%
pngUploadProcessing 194.94 ms +3.47% -2.22% 190.22 ms +6.38% -1.27% 2.48%
largeJpegUploadProcessing 1451.68 ms +0.91% -1.14% 1460.64 ms +0.85% -2.05% -0.61%
multipleImageUploadProcessing 1474.07 ms +1.43% -0.58% 1506.91 ms +1.03% -1.42% -2.18%

post-editor

Metric 4a97733 add/transform-scale % Change
serverResponse 455.88 ms +7.09% -5.37% 478.57 ms +2.23% -7.88% -4.74%
firstPaint 456.58 ms +5.22% -20.05% 405.59 ms +5.53% -5.04% 12.57%
domContentLoaded 819.69 ms +8.91% -2.22% 808.82 ms +1.65% -0.98% 1.34%
loaded 820.77 ms +8.89% -2.22% 809.96 ms +1.66% -0.96% 1.33%
firstContentfulPaint 478.11 ms +11.19% -4.94% 462.69 ms +5.14% -3.38% 3.33%
firstBlock 2204.85 ms +6.06% -1.25% 2204.56 ms +1.48% -1.86% 0.01%
type 17.38 ms +6.79% -14.21% 17.81 ms +5.11% -14.82% -2.41%
typeWithoutInspector 16.26 ms +12.85% -7.69% 16.34 ms +8.81% -6.55% -0.49%
typeWithTopToolbar 22.22 ms +3.92% -2.03% 22.23 ms +6.84% -2.2% -0.04%
typeContainer 7.97 ms +14.43% -6.9% 8.05 ms +3.6% -3.6% -0.99%
focus 116.91 ms +4.24% -4.93% 116.52 ms +3.63% -4.35% 0.33%
firstFocus 267.57 ms +0% -0% 254.68 ms +0% -0% 5.06%
selectAll 413.47 ms +0.78% -4.9% 419.35 ms +2.38% -0.91% -1.4%
undo 29.61 ms +6.52% -7.8% 28.49 ms +4.49% -5.34% 3.93%
listViewOpen 76.84 ms +10.14% -2.2% 83.91 ms +6.72% -12.93% -8.43%
inserterOpen 44.03 ms +7.18% -7.47% 41.31 ms +10.02% -6.87% 6.58%
inserterHover 11.71 ms +12.21% -14.69% 11.43 ms +5.69% -8.14% 2.45%
inserterSearch 7.7 ms +8.05% -6.88% 8.22 ms +7.91% -7.06% -6.33%
loadPatterns 670.29 ms +3.6% -5.91% 646.23 ms +6.96% -6.34% 3.72%
wpTotal 446.35 ms +7.15% -5.48% 468.86 ms +2.27% -8.02% -4.8%
wpMemoryUsage 14.81 MB +0% -0% 14.78 MB +0% -0% 0.24%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 4a97733 add/transform-scale % Change
serverResponse 468.53 ms +1.87% -5.61% 472.58 ms +1.39% -0.34% -0.86%
firstPaint 463.74 ms +3.02% -4.13% 437.23 ms +8.13% -8.7% 6.06%
domContentLoaded 838.28 ms +1.75% -0.87% 843.8 ms +1.32% -1.62% -0.65%
loaded 839.48 ms +1.72% -0.9% 844.91 ms +1.31% -1.6% -0.64%
firstContentfulPaint 475.38 ms +1.96% -2.15% 470.96 ms +4.46% -2.03% 0.94%
firstBlock 2602.83 ms +0.7% -0.77% 2620.48 ms +2.08% -0.34% -0.67%
type 17.01 ms +6.7% -2% 17.29 ms +10.82% -8.73% -1.62%
navigate 118.44 ms +8.32% -4.2% 116.98 ms +1.99% -3.33% 1.25%
loadPatterns 1384.32 ms +8.93% -8.26% 1340.96 ms +14.89% -13.14% 3.23%
loadPages 940.34 ms +0.87% -1.39% 974.15 ms +1.6% -1.99% -3.47%
wpTotal 459.08 ms +1.91% -5.76% 463 ms +1.39% -0.31% -0.85%
wpMemoryUsage 12.84 MB +0% -0% 12.82 MB +0% -0% 0.18%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

b23972e Run

🏁 Flaky tests

Some tests passed with failed attempts. The failures may not be related to this commit but are still reported for visibility. See the documentation for more information.

Navigates the list via UP/DOWN arrow keys from action buttons in /test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' }) with timeout 5000ms
  - waiting for getByRole('row', { name: 'Page Two Edit Actions' }).getByRole('button', { name: 'Edit' })
    14 × locator resolved to <button type="button" tabindex="-1" class="components-button is-small" id="view-list-0-173-primary-action-edit-post">Edit</button>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/dataviews-list-layout-keyboard.spec.js:243:5
Undo restores the post selection when another synced entity is loaded (RTC WebSocket) in /test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts, passed after 1 failed attempt.
Error: expect(received).toMatchObject(expected)

- Expected  - 2
+ Received  + 2

  Object {
    "attributeKey": "content",
    "blockIndex": 0,
    "content": "abcdef",
-   "endOffset": 3,
-   "offset": 3,
+   "endOffset": 6,
+   "offset": 6,
  }

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/collaboration/collaboration-undo-redo.spec.ts:363:5
does not select blocks in the canvas preview when editing from the sidebar (Site Editor v2) in /test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator: getByRole('combobox', { name: 'Search or type URL' })
Expected: focused
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeFocused" getByRole('combobox', { name: 'Search or type URL' }) with timeout 5000ms
  - waiting for getByRole('combobox', { name: 'Search or type URL' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:416:47)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:21
should reset a named font size using input field in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"small"} -->
+ <!-- wp:paragraph {"fontSize":"tiny"} -->
- <p class="has-small-font-size">Paragraph with font size reset using input field</p>
+ <p class="has-tiny-font-size">Paragraph with font size reset using input field</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:216:6
should reset a named font size using the tools panel menu in /test/e2e/specs/editor/various/font-size-picker.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:paragraph {"fontSize":"medium"} -->
+ <!-- wp:paragraph {"fontSize":"small"} -->
- <p class="has-medium-font-size">Paragraph with font size reset using tools panel menu</p>
+ <p class="has-small-font-size">Paragraph with font size reset using tools panel menu</p>
  <!-- /wp:paragraph -->

Call Log:
- Timeout 5000ms exceeded while waiting on the predicate
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/font-size-picker.spec.js:178:6
should select synced pattern in /test/e2e/specs/editor/various/writing-flow.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeFocused() failed

Locator:  locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
Expected: focused
Received: inactive
Timeout:  5000ms

Call log:
  - Expect "toBeFocused" locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]') with timeout 5000ms
  - waiting for locator('[name="editor-canvas"]').contentFrame().locator('[data-type="core/block"]')
    14 × locator resolved to <div tabindex="0" role="document" draggable="true" data-title="Pattern" data-type="core/block" data-is-drop-zone="true" aria-label="Block: Pattern" id="block-18f31781-85da-4d2c-a357-bd2cbfe2b794" data-block="18f31781-85da-4d2c-a357-bd2cbfe2b794" class="block-editor-block-list__block wp-block is-selected is-reusable block-library-block__reusable-block-container wp-block-block block-editor-block-list__layout">…</div>
       - unexpected value "inactive"

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/writing-flow.spec.js:1464:5

From 721927c, not the current head. Run

@aaronrobertshaw
aaronrobertshaw force-pushed the add/image-transform-support branch from 8917e05 to 9a43bf0 Compare November 17, 2026 12:05
@aaronrobertshaw
aaronrobertshaw force-pushed the add/image-transform-support branch from 9a43bf0 to 17f4c59 Compare November 17, 2026 13:41
@aaronrobertshaw
aaronrobertshaw force-pushed the add/image-transform-support branch from 17f4c59 to 3b049e0 Compare November 18, 2026 05:29
@aaronrobertshaw
aaronrobertshaw force-pushed the add/image-transform-support branch from 7bbe90f to c1103ef Compare November 18, 2026 07:43
@aaronrobertshaw
aaronrobertshaw force-pushed the add/image-transform-support branch from c1103ef to 721927c Compare November 18, 2026 08:22
@aaronrobertshaw
aaronrobertshaw force-pushed the add/image-transform-support branch from 721927c to 5b4a45f Compare November 19, 2026 12:02
Image skips serialization of the transform support and applies rotate,
translate and scale to its img with getTransformClassesAndStyles(), so
the caption stays put. The editor resize box carries the same inline
transform, and the transform feature selector also lists it, so Global
Styles and block style states reach it too.

The lightbox starts its zoom from the transformed image's centre and
scale, and the enlarged image drops the transform.
The rotate and offset tests used Image as a block with no transform
selector. Image now applies its transform to the img and the editor
resize box, so these cases move to Group to keep covering the wrapper,
and new cases check the Image selector in block states and Global
Styles.
@aaronrobertshaw
aaronrobertshaw force-pushed the add/image-transform-support branch from 5b4a45f to b23972e Compare November 19, 2026 14:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

[Block] Image Affects the Image Block [Feature] Design Tools Tools that impact the appearance of blocks both to expand the number of tools and improve the experi [Package] Block library /packages/block-library [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant