Skip to content

File Block: Add a Media section and a setup-state toolbar option - #84608

Open
im3dabasia wants to merge 7 commits into
trunkfrom
add/file-block-media-panel
Open

im3dabasia wants to merge 7 commits into
trunkfrom
add/file-block-media-panel

Conversation

@im3dabasia

@im3dabasia im3dabasia commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What?

See #66563.

File now offers media from the inspector and from the toolbar in its setup state, like Image, Cover, Media & Text and Site Logo.

Why?

1. The toolbar only appeared once a file was set, so it could replace but never add.
2. The inspector had no File section at all.

How?

Same pattern as #84602 (Video), worth reviewing that one first.

  • Toolbar and File panel move above the setup-state early return
  • Toolbar reads "Add file" when empty, "Replace" once set
  • The panel lives in edit.jsx rather than FileBlockInspector, since that reads href and would throw before a file is set
  • Copy URL stays behind the old condition, having no URL to copy when empty
  • Passes mediaType after Block Library: Show media type icons in the inspector media control #86170, so a file shows the file icon rather than an empty thumbnail

Screencast

Screen.Recording.2026-10-13.at.1.59.13.PM.mov

Testing Instructions

  1. Insert a File block and select it without adding media.
  2. The toolbar shows Add file, and the inspector shows a File section with the same.
  3. Add a file from either, the canvas updates and the filename appears.
  4. The control shows the file icon, not an empty thumbnail.
  5. Confirm Reset clears it and the toolbar then reads Replace.
  6. With a file set, Copy URL still sits after Replace.

On the duplication

Use of AI Tools

Claude Code. I reviewed and tested the change and take responsibility for it.

@im3dabasia im3dabasia self-assigned this Oct 13, 2026
@im3dabasia im3dabasia added [Type] Enhancement A suggestion for improvement. [Block] File Affects the File Block labels Oct 13, 2026
@github-actions github-actions Bot added the [Package] Block library /packages/block-library label Oct 13, 2026
@github-actions

github-actions Bot commented Oct 13, 2026 •

Copy link
Copy Markdown

🤖 PR meta 🤖

🎉 Props

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: im3dabasia <im3dabasia1@git.wordpress.org>
Co-authored-by: t-hamano <wildworks@git.wordpress.org>
Co-authored-by: jameskoster <jameskoster@git.wordpress.org>
Co-authored-by: fcoveram <fcoveram@git.wordpress.org>
Co-authored-by: jasmussen <joen@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.


Props Bot commands

You can trigger Props Bot actions by commenting on this PR:

  • @propsbot add <username> to give props to a GitHub user. Requires write access.
  • @propsbot remove <username> to leave a user out of the props. Requires write access.
  • @propsbot refresh to refresh this list. Adding the props-bot label works too.

Updated as activity occurs, without notifying anyone named here. Add the props-bot label to refresh.

📦 Bundle size

Size Change: +119 B (0%)

Total Size: 8.9 MB

📦 View Changed
Filename Size Change
build/scripts/block-library/index.min.js 442 kB +119 B (+0.03%)

From 6662184, not the current head. Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 8a8cc5a trunk % Change
timeToFirstByte 45.2 ms +8.63% -3.1% 45.6 ms +4.82% -4.5% -0.88%
largestContentfulPaint 78 ms +5.13% -12.82% 74 ms +8.11% -5.41% 5.41%
lcpMinusTtfb 31.9 ms +4.39% -24.92% 27.35 ms +11.15% -10.6% 16.64%
wpBeforeTemplate 23.2 ms +14.18% -2.33% 23.29 ms +3.31% -2.19% -0.39%
wpTemplate 18.11 ms +7.29% -6.41% 18.44 ms +2.93% -5.59% -1.79%
wpTotal 41.74 ms +9.22% -3.5% 42.1 ms +4.44% -4.61% -0.86%
wpMemoryUsage 7.75 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 8a8cc5a trunk % Change
timeToFirstByte 36.7 ms +8.72% -1.63% 37.3 ms +6.7% -2.55% -1.61%
largestContentfulPaint 68 ms +5.88% -5.88% 66 ms +3.03% -3.03% 3.03%
lcpMinusTtfb 30.35 ms +3.46% -6.92% 28.2 ms +2.84% -1.95% 7.62%
wpBeforeTemplate 19.99 ms +5.1% -2.8% 20.27 ms +6.07% -1.78% -1.38%
wpTemplate 13.79 ms +2.47% -3.19% 13.85 ms +6.14% -1.44% -0.43%
wpTotal 33.81 ms +9.02% -1.95% 34.53 ms +6.34% -3.04% -2.09%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 8a8cc5a trunk % Change
mediaProcessingJpeg 332.85 ms +0.75% -0.84% 330.74 ms +1% -0.12% 0.64%
mediaProcessingAvif 4898.58 ms +0.32% -0.79% 4896.61 ms +0.28% -0.82% 0.04%
mediaProcessingJpegToAvif 3400.61 ms +0.12% -0.35% 3413.04 ms +0.45% -0.04% -0.36%

media-upload

Metric 8a8cc5a trunk % Change
jpegUploadProcessing 1479.1 ms +2.6% -0.58% 1466.82 ms +1.21% -0.46% 0.84%
pngUploadProcessing 259.25 ms +2.11% -7.32% 261.8 ms +19.19% -8.27% -0.97%
largeJpegUploadProcessing 1467.94 ms +0.82% -1.27% 1462.68 ms +1.65% -0.82% 0.36%
multipleImageUploadProcessing 1524.37 ms +4.11% -0.6% 1518.13 ms +1.27% -0.28% 0.41%

post-editor

Metric 8a8cc5a trunk % Change
serverResponse 275.38 ms +2.02% -3.83% 263.71 ms +2.82% -9.57% 4.43%
firstPaint 316.31 ms +5.39% -4.41% 272.67 ms +3.54% -4.72% 16%
domContentLoaded 567.4 ms +3.5% -3.39% 542.07 ms +1.18% -2.25% 4.67%
loaded 568.32 ms +3.49% -3.4% 542.83 ms +1.18% -2.25% 4.7%
firstContentfulPaint 328.48 ms +7.46% -5.07% 315.93 ms +0.31% -1.89% 3.97%
firstBlock 1531.27 ms +5.13% -3.44% 1431.26 ms +3.14% -1.59% 6.99%
type 13.22 ms +3.71% -10.74% 12.68 ms +7.49% -10.73% 4.26%
typeWithoutInspector 13.67 ms +4.61% -12.36% 12.95 ms +4.94% -9.19% 5.56%
typeWithTopToolbar 17.83 ms +4.26% -7.01% 16.67 ms +2.22% -5.64% 6.96%
typeContainer 5.87 ms +10.56% -4.43% 6.16 ms +0.97% -5.68% -4.71%
focus 84.19 ms +10.17% -5.18% 67.76 ms +4.59% -5.48% 24.25%
firstFocus 193.64 ms +0% -0% 160.09 ms +0% -0% 20.96%
selectAll 251.13 ms +3.66% -1.73% 232.56 ms +1.63% -0.05% 7.99%
undo 20.98 ms +15.44% -4.05% 20.53 ms +9.06% -4.53% 2.19%
listViewOpen 26.93 ms +4.49% -5.42% 26.92 ms +10.22% -5.53% 0.04%
inserterOpen 26.9 ms +1.45% -4.46% 29.29 ms +15.06% -5.5% -8.16%
inserterHover 7.7 ms +6.1% -5.71% 8.44 ms +4.74% -8.29% -8.77%
inserterSearch 6.52 ms +2.45% -8.59% 6.6 ms +20.91% -5.3% -1.21%
loadPatterns 425.25 ms +3.66% -1.73% 427.15 ms +4.29% -5.31% -0.44%
wpTotal 268 ms +2.21% -3.87% 256.88 ms +3.01% -9.83% 4.33%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 8a8cc5a trunk % Change
serverResponse 315.18 ms +1.08% -7.79% 302.36 ms +6.82% -4.25% 4.24%
firstPaint 370.48 ms +3.93% -9.84% 358.12 ms +7.84% -10.7% 3.45%
domContentLoaded 671.13 ms +1.38% -1.73% 677.2 ms +0.33% -1.05% -0.9%
loaded 671.93 ms +1.38% -1.72% 678.07 ms +0.32% -1.07% -0.91%
firstContentfulPaint 377.99 ms +1.87% -1.03% 383.11 ms +0.86% -1.84% -1.34%
firstBlock 2051.81 ms +1.38% -0.79% 2091.06 ms +0.92% -1.64% -1.88%
type 14.64 ms +11.13% -13.05% 14.9 ms +2.48% -12.55% -1.74%
navigate 88.67 ms +15.2% -2.42% 89.92 ms +7.61% -6.82% -1.39%
loadPatterns 1220.31 ms +5.57% -7.06% 1166.66 ms +0.78% -9.27% 4.6%
loadPages 953.23 ms +6.78% -3.85% 994.43 ms +2.45% -3.94% -4.14%
wpTotal 306.84 ms +1.08% -8.45% 293.99 ms +6.98% -4.43% 4.37%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

64f3fa7 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.

As a user I want to be able to create a navigation overlay for a specific navigation block in /test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: /(Editor publish|Save panel)/ }).getByRole('button', { name: 'Save', exact: true })

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:48:5)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-overlay-template-part.spec.js:91:4
closes the new note form on focus-out only when empty in /test/e2e/specs/editor/various/block-notes.spec.js, passed after 1 failed attempt.
Error: locator.focus: Error: strict mode violation: getByRole('region', { name: 'Editor top bar' }).getByRole('button', { name: 'Options' }) resolved to 2 elements:
    1) <button id="_r_3u_" type="button" aria-haspopup="true" aria-label="Options" aria-expanded="false" data-active-item="true" data-toolbar-item="true" class="components-button components-dropdown-menu__toggle has-icon">…</button> aka getByRole('toolbar', { name: 'Block tools' }).getByRole('button', { name: 'Options' })
    2) <button tabindex="0" type="button" id="base-ui-_r_k_" aria-haspopup="menu" aria-label="Options" aria-expanded="false" class="components-button is-compact has-icon">…</button> aka locator('#base-ui-_r_k_')

Call log:
  - waiting for getByRole('region', { name: 'Editor top bar' }).getByRole('button', { name: 'Options' })

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/various/block-notes.spec.js:1380:24
should undo without broken temporary state in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Error: expect(received).toBe(expected) // Object.is equality

- Expected  - 2
+ Received  + 2

- <!-- wp:image -->
- <figure class="wp-block-image"><img alt=""/></figure>
+ <!-- wp:image {"id":21,"sizeSlug":"full","linkDestination":"none"} -->
+ <figure class="wp-block-image size-full"><img src="http://localhost:8889/wp-content/uploads/2026/11/bcd83bf5-cd60-4159-98a1-46e8384d11f9.png" alt="" class="wp-image-21"/></figure>
  <!-- /wp:image -->
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/image.spec.js:432:49

64f3fa7 Run

@jameskoster

Copy link
Copy Markdown
Contributor

I don't object to the Inspector control, but it's a shame that it puts other settings one click further away in favor of something that can already be set via the toolbar and the placeholder state. Curious how others feel about this one.

@im3dabasia
im3dabasia requested a review from t-hamano October 14, 2026 10:28
@fcoveram

Copy link
Copy Markdown
Contributor

I don't object to the Inspector control, but it's a shame that it puts other settings one click further away in favor of something that can already be set via the toolbar and the placeholder state. Curious how others feel about this one.

I feel the same and shared the same point in #73466, among other concerns. Since the edit or design mode idea has lost appeal and pattern editing continues, the Content tab seems the right place for this, but I would make it less prominent.

To connect this with #84605, I lean toward creating rules for what to show inside the control and making the different states clearer. I will elaborate more about this in #84605

@jasmussen

Copy link
Copy Markdown
Contributor

Since the edit or design mode idea has lost appeal and pattern editing continues, the Content tab seems the right place for this, but I would make it less prominent.

This point is valid, the problem is for things like Site Logo where this would mean three tabs even if the second "settings" tab is not that used at the moment.

image

It sounds like you're about to comment on a larger strategy, which is valid, so just for awareness before I saw your comment about this concern, I posted #66563 (comment) which suggested still proceeding.

I'll pause that work though, and wait for your ideas.

For me the main problem to solve is still this:

2026-10-20 11 19 39 localhost 652c0c44a677

The dropzone, even the button inside can disappear if the logo is made smaller, is not very ergonomic, and the inspector CTA to add a site logo feels like a more intuitive way to add a logo.

Images, Cover blocks, File blocks, Embeds, all blocks that feature placeholders can be 20x20px blocks in the canvas, and when they are so small, there needs to be some simple way of adding media to them—escaping their setup state.

@fcoveram

fcoveram commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

I shared an idea in #66563 about how the control handles different media types.

@im3dabasia

im3dabasia commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased on #86170, so a file now shows the file icon rather than an empty thumbnail.

@t-hamano both your points above are addressed. Would you be able to take another look?

image

One open question from the issue, the panel sits in the Content tab, which gives File a third tab. @jasmussen you raised this for Site Logo, happy to move it to Settings if that's preferred.

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] File Affects the File Block [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.

5 participants