Skip to content

Audio Block: Add a Media section and a setup-state toolbar option - #84605

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

im3dabasia merged 10 commits into
trunkfrom
add/audio-block-media-panel

Conversation

@im3dabasia

@im3dabasia im3dabasia commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

What?

See #66563. Audio 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 audio was set, so it could replace but never add.
2. The inspector had no Media section at all.

How?

Follows #84602, which does the same for Video. Worth reviewing that one first, this is the same change applied to a near-identical file.

  • Lifts the toolbar and Media panel above the setup-state early return, as #82420 did for Media & Text
  • Toolbar reads "Add audio" when empty, "Replace" once set
  • Panel uses the Content group and MediaControl, matching the blocks that already have it
  • Forwards accept through MediaControl so the sidebar restricts to audio like the toolbar does. Additive and optional, nothing changes for existing callers

Screencast

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

Testing Instructions

  1. Insert an Audio block and select it without adding media.
  2. The toolbar shows Add audio, and the inspector shows a Media section with the same.
  3. Add audio from either, the canvas updates and the filename appears.
  4. Confirm Reset clears it and the toolbar then reads Replace.

Note

The accept passthrough is the same three lines as in #84602, so whichever merges second will either apply cleanly or need a one-line conflict resolution.

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] Audio Affects the Audio 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: jasmussen <joen@git.wordpress.org>
Co-authored-by: fcoveram <fcoveram@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: +138 B (0%)

Total Size: 8.85 MB

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

9ed2726 Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric 2acf3db trunk % Change
timeToFirstByte 46.45 ms +6.24% -6.57% 45.25 ms +13.04% -2.1% 2.65%
largestContentfulPaint 72 ms +11.11% -0% 78 ms +7.69% -10.26% -7.69%
lcpMinusTtfb 29.7 ms +14.65% -16.84% 31.2 ms +9.46% -16.35% -4.81%
wpBeforeTemplate 23.53 ms +7.35% -5.06% 23.85 ms +12.08% -2.89% -1.34%
wpTemplate 17.72 ms +11.85% -9.31% 17.67 ms +9.96% -5.89% 0.28%
wpTotal 42.68 ms +5.53% -7.01% 41.74 ms +12.63% -3.09% 2.25%
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 2acf3db trunk % Change
timeToFirstByte 38.6 ms +5.83% -5.57% 38.4 ms +7.94% -2.73% 0.52%
largestContentfulPaint 68 ms +5.88% -0% 68 ms +5.88% -0% 0%
lcpMinusTtfb 29.95 ms +5.84% -2.34% 30.65 ms +4.08% -2.45% -2.28%
wpBeforeTemplate 20.71 ms +4.73% -3.19% 21.14 ms +8.89% -2.98% -2.03%
wpTemplate 13.62 ms +7.49% -4.77% 13.55 ms +4.94% -2.21% 0.52%
wpTotal 35.57 ms +5.9% -6.47% 35.03 ms +8.34% -2.57% 1.54%
wpMemoryUsage 6.44 MB +0% -0% 6.41 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric 2acf3db trunk % Change
mediaProcessingJpeg 260.72 ms +2.06% -1.19% 265.27 ms +1.31% -1.31% -1.72%
mediaProcessingAvif 4247.6 ms +0.59% -0.56% 4251.73 ms +1.94% -0.18% -0.1%
mediaProcessingJpegToAvif 2977.67 ms +0.52% -0.71% 2961.55 ms +1.41% -0.07% 0.54%

media-upload

Metric 2acf3db trunk % Change
jpegUploadProcessing 1475.79 ms +1.25% -1.51% 1467.86 ms +1.11% -0.74% 0.54%
pngUploadProcessing 238.04 ms +3.64% -5.57% 257.92 ms +2.38% -1.78% -7.71%
largeJpegUploadProcessing 1449.88 ms +0.56% -0.44% 1443.71 ms +0.88% -0.86% 0.43%
multipleImageUploadProcessing 1538.52 ms +0.54% -2.56% 1556.21 ms +0.48% -1.52% -1.14%

post-editor

Metric 2acf3db trunk % Change
serverResponse 332.69 ms +1.62% -5.33% 321.28 ms +4.98% -7.96% 3.55%
firstPaint 365.41 ms +1.86% -14.01% 319.9 ms +17.14% -4.44% 14.23%
domContentLoaded 665.98 ms +2.39% -1.7% 684.06 ms +1% -2.12% -2.64%
loaded 667.39 ms +2.36% -1.68% 685.46 ms +1.03% -2.08% -2.64%
firstContentfulPaint 369.3 ms +0.79% -1.7% 374.82 ms +1.5% -2.11% -1.47%
firstBlock 1823.39 ms +0.61% -0.86% 1829.43 ms +0.37% -0.61% -0.33%
type 15.18 ms +8.5% -10.08% 15.92 ms +5.09% -7.6% -4.65%
typeWithoutInspector 15.25 ms +5.18% -11.54% 16.97 ms +7.54% -15.14% -10.14%
typeWithTopToolbar 19.11 ms +4.81% -3.92% 20.07 ms +8.52% -3.84% -4.78%
typeContainer 6.82 ms +7.77% -4.4% 7 ms +8.29% -3% -2.57%
focus 92.77 ms +6.62% -6.45% 86.1 ms +2.94% -3.23% 7.75%
firstFocus 203.31 ms +0% -0% 225.15 ms +0% -0% -9.7%
selectAll 326.17 ms +0.21% -2.78% 321.65 ms +0.47% -1.59% 1.41%
undo 27.28 ms +6.23% -6.2% 25.68 ms +5.14% -4.98% 6.23%
listViewOpen 30.64 ms +3.95% -0.65% 32.83 ms +6.79% -11.18% -6.67%
inserterOpen 35.36 ms +7.18% -16.35% 33.16 ms +13.66% -9.89% 6.63%
inserterHover 9.78 ms +6.75% -4.09% 9.82 ms +6.31% -6.82% -0.41%
inserterSearch 7.3 ms +5.07% -6.99% 7.14 ms +5.74% -3.64% 2.24%
loadPatterns 533.65 ms +1.3% -2.77% 531.86 ms +5.68% -6.15% 0.34%
wpTotal 324.02 ms +1.67% -5.52% 312.61 ms +5.09% -8.26% 3.65%
wpMemoryUsage 14.80 MB +0% -0% 14.76 MB +0% -0% 0.25%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric 2acf3db trunk % Change
serverResponse 480.98 ms +0.91% -8.76% 474.72 ms +0.63% -9.14% 1.32%
firstPaint 378.94 ms +20.5% -1.12% 442.3 ms +9.22% -8.32% -14.33%
domContentLoaded 858.92 ms +3.48% -1.59% 841.96 ms +1.35% -0.76% 2.01%
loaded 860.41 ms +3.49% -1.56% 843.67 ms +1.34% -0.77% 1.98%
firstContentfulPaint 471.75 ms +4.08% -1.62% 480.05 ms +2.47% -3.44% -1.73%
firstBlock 2696.57 ms +1.51% -0.75% 2636.51 ms +0.81% -0.86% 2.28%
type 18.95 ms +5.44% -8.23% 18.52 ms +9.18% -13.28% 2.32%
navigate 114.44 ms +2.74% -1.77% 113.88 ms +4.76% -1.89% 0.49%
loadPatterns 1733.05 ms +9.75% -1.09% 1704.79 ms +2.09% -7.46% 1.66%
loadPages 968.64 ms +2.55% -0.52% 982.03 ms +2.74% -1.98% -1.36%
wpTotal 471.59 ms +0.85% -8.95% 465.2 ms +0.62% -9.34% 1.37%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.28%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

9ed2726 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.

should give the image its context menu while selected @WebKit @Firefox in /test/e2e/specs/editor/blocks/image.spec.js, passed after 1 failed attempt.
Test timeout of 100000ms exceeded.

9ed2726 Run

@im3dabasia
im3dabasia requested review from a team and Mamaduka October 13, 2026 09:54

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR. I'm generally in favor of this PR, but my only concern is that audio files never have thumbnails. This means it ends up looking like this:

Image

This concern also applies to the PR for the file block. Maybe we need some kind of option to not display the thumbnail 🤔

mediaUrl={ src }
filename={ getFilename( src ) }
allowedTypes={ ALLOWED_MEDIA_TYPES }
accept="audio/*"

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is needed either. Since allowedTypes is already set, MediaReplaceFlow derives the accept attribute from the allowed audio MIME types, so there's no need to add a new accept prop to MediaControl. See #84608 (comment) for details.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Dropped it, thanks. 1af75c2

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking more widely, the same thing appears in around 14 places, Video, Audio, Playlist, Playlist Track, Post Featured Image, File, and the background image control, all passing accept alongside allowedTypes, which skips the server MIME check.

Tentative for now, but it seems like a good list to start with. Happy to open a separate PR.

@im3dabasia

Copy link
Copy Markdown
Contributor Author

Maybe we need some kind of option to not display the thumbnail 🤔

Agreed on the thumbnail, following up separately with an icon fallback, since it affects Cover's video backgrounds too. Discussed on #66563.

@jasmussen

Copy link
Copy Markdown
Contributor

Something to consider: a file type indicator, which could be useful in DataViews contexts as well. Could be an audio icon, tiny, inside the square. There will be a future question around .md files, .pdf files, etc, but it could be a destination to aspire to. In the mean time, is there a simple way to hide the square indicator, if there's no thumbnail provided?

@fcoveram

fcoveram commented Oct 20, 2026 •

Copy link
Copy Markdown
Contributor

I shared an idea in #66563 for the control handling different media types.

@t-hamano t-hamano left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me from a code perspective. @WordPress/gutenberg-design, could you please confirm once again if this design direction is correct?

image

@im3dabasia

Copy link
Copy Markdown
Contributor Author

@WordPress/gutenberg-design friendly nudge on this one:

@t-hamano has approved the code side, so it just needs a quick check on the design direction.

Would appreciate your feedback on this. Thanks!

@jasmussen

Copy link
Copy Markdown
Contributor

Looks good on my end.

@im3dabasia
im3dabasia requested review from a team and removed request for a team November 30, 2026 09:47
@im3dabasia

Copy link
Copy Markdown
Contributor Author

Thanks @jasmussen!

@t-hamano, with design signed off, could you approve this one if it looks good? The Video (#84602) and File (#84608) PRs have the same change, and I've addressed your feedback on both, so they're ready for another look whenever you have time.

@im3dabasia
im3dabasia requested a review from t-hamano December 2, 2026 13:39
@t-hamano

t-hamano commented Dec 3, 2026

Copy link
Copy Markdown
Contributor

@im3dabasia can you resolve the merge conflicts? edit.jsx has been converted to TypeScript in trunk.

im3dabasia and others added 2 commits December 3, 2026 15:44
@im3dabasia
im3dabasia enabled auto-merge (squash) December 3, 2026 10:17
@im3dabasia
im3dabasia merged commit e88bf81 into trunk Dec 3, 2026
81 checks passed
@im3dabasia
im3dabasia deleted the add/audio-block-media-panel branch December 3, 2026 10:34
@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] Audio Affects the Audio 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.

4 participants