Skip to content

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

Merged
im3dabasia merged 12 commits into
trunkfrom
add/file-block-media-panel
Dec 3, 2026
Merged

im3dabasia merged 12 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: +151 B (0%)

Total Size: 8.85 MB

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

aa377e0 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 26360f9 trunk % Change
timeToFirstByte 58.55 ms +12.04% -6.15% 60.45 ms +7.53% -2.32% -3.14%
largestContentfulPaint 90 ms +6.67% -6.67% 92 ms +8.7% -4.35% -2.17%
lcpMinusTtfb 30.05 ms +15.14% -6.66% 30.4 ms +4.77% -4.11% -1.15%
wpBeforeTemplate 30.39 ms +14.48% -2.3% 31.34 ms +13.75% -1.91% -3.03%
wpTemplate 23.48 ms +6.3% -6.98% 24.5 ms +2% -3.51% -4.16%
wpTotal 54.56 ms +12.08% -6.16% 55.98 ms +8.81% -1.77% -2.54%
wpMemoryUsage 7.76 MB +0% -0% 7.72 MB +0% -0% 0.45%
wpDbQueries 16 +0% -0% 16 +0% -0% 0%

front-end-classic-theme

Metric 26360f9 trunk % Change
timeToFirstByte 49 ms +4.8% -2.55% 50.8 ms +4.33% -2.66% -3.54%
largestContentfulPaint 84 ms +4.76% -0% 88 ms +4.55% -4.55% -4.55%
lcpMinusTtfb 35.8 ms +2.79% -2.79% 36 ms +6.81% -2.92% -0.56%
wpBeforeTemplate 27.98 ms +4.36% -0.89% 28.67 ms +9.28% -1.12% -2.41%
wpTemplate 17.49 ms +2.8% -4.4% 17.98 ms +3.62% -3.89% -2.73%
wpTotal 45.78 ms +5.46% -2.73% 47.55 ms +4.25% -2.5% -3.72%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 26360f9 trunk % Change
mediaProcessingJpeg 400.42 ms +1.92% -0.52% 407.86 ms +0.29% -1.2% -1.82%
mediaProcessingAvif 6148.63 ms +0.66% -0.2% 6148.83 ms +0.5% -0.05% 0%
mediaProcessingJpegToAvif 4258.4 ms +0.22% -0.24% 4247.58 ms +0.2% -0.1% 0.25%

media-upload

Metric 26360f9 trunk % Change
jpegUploadProcessing 1980.23 ms +3.26% -19.97% 1770.67 ms +12.71% -14.43% 11.84%
pngUploadProcessing 285.01 ms +1.23% -8.43% 295.63 ms +7.88% -1.65% -3.59%
largeJpegUploadProcessing 1993.65 ms +1.44% -23.29% 2004.77 ms +0.62% -0.86% -0.55%
multipleImageUploadProcessing 2115.39 ms +0.35% -0.64% 2138.36 ms +1.63% -0.68% -1.07%

post-editor

Metric 26360f9 trunk % Change
serverResponse 327.49 ms +1.42% -11.88% 320.85 ms +3.34% -10.38% 2.07%
firstPaint 311.36 ms +11.51% -2.49% 316.96 ms +9.28% -6.99% -1.77%
domContentLoaded 643.7 ms +0.74% -0.4% 642.82 ms +1.78% -0.98% 0.14%
loaded 644.96 ms +0.72% -0.41% 644.14 ms +1.78% -1% 0.13%
firstContentfulPaint 357.14 ms +3.48% -1.5% 363.3 ms +2.75% -0.91% -1.7%
firstBlock 1749.41 ms +1.12% -1.63% 1726.61 ms +1.29% -1.38% 1.32%
type 15.03 ms +8.12% -9.71% 15.58 ms +1.48% -9.5% -3.53%
typeWithoutInspector 15.1 ms +4.44% -9.01% 14.71 ms +7.27% -12.85% 2.65%
typeWithTopToolbar 19.49 ms +6% -4.98% 19.18 ms +6.26% -11.11% 1.62%
typeContainer 6.88 ms +2.76% -5.52% 6.62 ms +5.14% -1.96% 3.93%
focus 87.23 ms +7.19% -4.72% 87.92 ms +4.21% -12.63% -0.78%
firstFocus 203.61 ms +0% -0% 201 ms +0% -0% 1.3%
selectAll 309.01 ms +2.76% -1.25% 311.72 ms +0.71% -1.44% -0.87%
undo 22.86 ms +5.99% -2.58% 25.63 ms +4.84% -7.22% -10.81%
listViewOpen 29.72 ms +4.21% -7.1% 32.64 ms +13.6% -3.65% -8.95%
inserterOpen 31.67 ms +11.18% -7.55% 33.62 ms +6.1% -14.87% -5.8%
inserterHover 9.41 ms +4.57% -8.93% 10.3 ms +2.33% -7.57% -8.64%
inserterSearch 6.98 ms +7.31% -3.58% 7.31 ms +3.42% -8.21% -4.51%
loadPatterns 512.73 ms +0.83% -1.78% 552.59 ms +1.16% -1.35% -7.21%
wpTotal 318.96 ms +1.41% -12.26% 312.36 ms +3.4% -10.69% 2.11%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 26360f9 trunk % Change
serverResponse 314.59 ms +0.4% -8.1% 321.13 ms +1.42% -5.39% -2.04%
firstPaint 333.88 ms +11.08% -10.83% 306.77 ms +22.15% -5.95% 8.84%
domContentLoaded 649.86 ms +0.48% -0.43% 657.64 ms +1.1% -0.57% -1.18%
loaded 651.04 ms +0.48% -0.41% 658.88 ms +1.1% -0.56% -1.19%
firstContentfulPaint 368.91 ms +0.53% -1.62% 367.08 ms +2.85% -2.47% 0.5%
firstBlock 2021.76 ms +0.79% -0.51% 2036.1 ms +1.92% -0.89% -0.7%
type 14.79 ms +8.05% -8.99% 15.2 ms +4.74% -3.49% -2.7%
navigate 87.36 ms +9% -4.89% 92.8 ms +11.02% -3.05% -5.86%
loadPatterns 1209.14 ms +3.43% -0.87% 1346.66 ms +8.51% -4.92% -10.21%
loadPages 1032.16 ms +0.46% -2.23% 1028.93 ms +1.86% -1.01% 0.31%
wpTotal 306.35 ms +0.39% -8.31% 312.76 ms +1.43% -5.49% -2.05%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

aa377e0 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.

Overlay menu interactions in Safari (@WebKit) in /test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js, passed after 1 failed attempt.
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for getByRole('region', { name: 'Editor top bar' }).getByRole('button', { name: 'Save', exact: true })
    - locator resolved to <button type="button" aria-disabled="true" class="components-button editor-post-publish-button editor-post-publish-button__button is-primary is-compact">Save</button>
  - attempting click action
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
    - waiting 20ms
    2 × waiting for element to be visible, enabled and stable
      - element is not enabled
    - retrying click action
      - waiting 100ms
    16 × waiting for element to be visible, enabled and stable
       - element is not enabled
     - retrying click action
       - waiting 500ms

    at Editor.saveSiteEditorEntities (/home/runner/work/gutenberg/gutenberg/packages/e2e-test-utils-playwright/src/editor/site-editor.ts:39:22)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/blocks/navigation-frontend-interactivity.spec.js:40:4
should allow user to add and remove multiple local font files in /test/e2e/specs/admin/font-library.spec.js, passed after 1 failed attempt.
Error: expect(locator).toBeVisible() failed

Locator: getByLabel('Exo 2 Semi-bold Italic')
Expected: visible
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" getByLabel('Exo 2 Semi-bold Italic') with timeout 5000ms
  - waiting for getByLabel('Exo 2 Semi-bold Italic')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/admin/font-library.spec.js:58:6

yields to All notes when the canvas is too narrow in /test/e2e/specs/editor/various/block-notes-floating.spec.js, passed after 1 failed attempt.

aa377e0 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.

@t-hamano

t-hamano commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

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.

I believe the panel should stay in the Content tab rather than move to the Settings tab. A file is content, so it should be editable even in pattern editing mode (contentOnly). If we moved it to the Settings tab, the file couldn't be replaced without first clicking the "Edit pattern" button. This would also be consistent with Image, Cover, and Media & Text, which already place their media panel in the Content tab.

The same applies to the similar PRs: #84605 and #84602.

@fcoveram

fcoveram commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

+1 to @t-hamano by keeping the control in Content tab.

How does this relate to the work made in #86732? The control component described in #84181 is still open but, if I understand correctly, that component should eventually replace this one. Am I correct?

im3dabasia and others added 2 commits December 3, 2026 15:44
Co-authored-by: Aki Hamano <54422211+t-hamano@users.noreply.github.com>
@im3dabasia
im3dabasia enabled auto-merge (squash) December 3, 2026 10:17
@t-hamano

t-hamano commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

How does this relate to the work made in #86732? The control component described in #84181 is still open but, if I understand correctly, that component should eventually replace this one. Am I correct?

@fcoveram My understanding is that #84181 and #86732 are for selecting files from your computer, like uploading fonts in the Font Library. The control in this PR, on the other hand, mainly opens the Media Library.

So I don't think the file input UI would directly replace this media control, but we could probably use its new design as a reference to improve this control.

@fcoveram

fcoveram commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

Thanks for the clarification.

84181 and 86732 are for selecting files from your computer, like uploading fonts in the Font Library. The control in this PR, on the other hand, mainly opens the Media Library.

I don't see much differences in the action they trigger but I understand where they come from.

[…] we could probably use its new design as a reference to improve this control.

Agree.

My comment doesn't aim to block so +1 to continue and treat the design consistency as a follow-up

@im3dabasia
im3dabasia merged commit e9c2643 into trunk Dec 3, 2026
93 of 96 checks passed
@im3dabasia
im3dabasia deleted the add/file-block-media-panel branch December 3, 2026 11:44
@github-actions github-actions Bot added this to the Gutenberg 24.7 milestone Dec 3, 2026
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