Skip to content

Client Side Media: Optimize previously uploaded media - #79509

Draft
adamsilverstein wants to merge 34 commits into
trunkfrom
feature/79364-optimize-existing-media
Draft

adamsilverstein wants to merge 34 commits into
trunkfrom
feature/79364-optimize-existing-media

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Jun 24, 2026 •

Copy link
Copy Markdown
Member

What?

Adds the ability to optimize previously uploaded media using the client-side (WASM/libvips) pipeline, gated behind a new "Optimize existing media" experiment. When the experiment is enabled, a new "Optimize" control appears in the inspector of image-bearing blocks; clicking it fetches the attachment's original file, re-compresses it in the browser, regenerates sub-sizes, uploads the result as a new attachment, and repoints the block at it.

Closes #79364

Why?

Client-side media currently optimizes media only at upload time. Sites that predate the feature (or media uploaded before it was enabled) get no benefit. This lets users re-process existing media (e.g. compress a legacy JPEG, regenerate sub-sizes) using the same in-browser pipeline, with graceful fallback when the browser can't process an item. This is one of the capabilities called out for the 7.1 cycle.

Per review feedback (swissspidy, andrewserong), the UI ships behind an experiment so the exposure (sidebar panel vs. command palette vs. admin/bulk UI) can continue to be refined with design input before it is on by default.

How?

Experiment gating:

  • New gutenberg-optimize-existing-media experiment registered in the Media group on the Experiments screen (lib/experimental/experiments/load.php).
  • gutenberg_enable_experiments() bridges it to the editor as window.__experimentalOptimizeExistingMedia (lib/experimental/editor-settings.php).
  • The inspector panel only renders when the experiment flag is set (in addition to the existing client-side media processing checks).

Store (@wordpress/upload-media):

  • New public action optimizeExistingItem( { id, url, fileName, onSuccess, onError, additionalData } ) that enqueues a queue item (with sourceUrl/sourceAttachmentId and a StubFile placeholder) whose operations are [ FetchRemoteFile, TranscodeImage(same format), Upload, ThumbnailGeneration, Finalize ].
  • New FetchRemoteFile operation + fetchFile() utility to download the original by URL.
  • Reuses the existing TranscodeImage operation for same-format re-compression (no duplicate Compress op), and the existing sideload/finalize chain to regenerate sub-sizes.
  • New FETCH_REMOTE_FILE_ERROR code. Unsupported/unprocessable formats are skipped via onError, leaving the original attachment untouched.

UI (@wordpress/editor):

  • An editor.BlockEdit filter adds an "Optimize" inspector panel to core/image, core/cover, core/media-text, core/post-featured-image, and core/site-logo. (Gallery items are themselves core/image blocks, so they're covered when selected.)
  • The control resolves the block's attachment, optimizes its full-size original, repoints the block at the new attachment, and reports progress/errors via snackbars (spinner driven by isUploadingById).
  • Gated on window.__experimentalOptimizeExistingMedia, window.__clientSideMediaProcessing, and isClientSideMediaSupported().

The optimized result is uploaded as a new attachment and the block is repointed at it (matching the media-experiments prototype). This reuses the existing mediaUpload/mediaSideload/mediaFinalize settings, so no PHP/REST changes are required.

Screencast

optimize.existing.mp4

Testing Instructions

Test in WordPress Playground

Test with Playground: https://playground.wordpress.net/?gutenberg-pr=79509

  1. Go to Settings → Experiments and enable Optimize existing media.
  2. Insert an Image block and upload a JPEG/PNG.
  3. In the block inspector, expand the Optimize panel and click Optimize image.
  4. Confirm a spinner shows, a success snackbar appears, and the block now points at a new -optimized attachment that is no larger than the original.
  5. Repeat for a Cover, Media & Text, Featured Image, and Site Logo block.
  6. Disable the experiment and confirm the Optimize panel no longer appears.

Automated

  • npm run test:unit packages/upload-media — store unit tests for optimizeExistingItem and fetchRemoteFile.
  • npm run test:e2e -- test/e2e/specs/editor/various/client-side-media-processing.spec.js — "optimizes a previously uploaded image into a new attachment" (enables the experiment for its scope).

Out of scope (follow-ups)

  • Bulk action / Media Library integration to optimize many items (part of Client Side Media iteration for WordPress 7.1 #76756 / media library rebuild).
  • Before/after approval dialog.
  • Command palette entry for optimizing images (suggested in review).
  • Format conversion (WebP/AVIF) and original-lineage meta to prevent double-compression on repeated runs.

…ration

Add the store primitives to re-process an already-uploaded attachment
client-side: a public optimizeExistingItem action that enqueues a queue
item which fetches the original file, re-compresses it (same format) via
the existing TranscodeImage operation, uploads the result as a new
attachment, and regenerates sub-sizes.

Introduce the FetchRemoteFile operation (and a fetchFile utility) to
download an existing file by URL, and a FETCH_REMOTE_FILE_ERROR code.
Unsupported or unprocessable formats are skipped via onError, leaving the
original attachment untouched.

Part of #79364.
…images

Register an editor.BlockEdit filter that adds an "Optimize" inspector
panel to image-bearing blocks (image, cover, media-text,
post-featured-image, site-logo). The control resolves the block's
attachment, dispatches optimizeExistingItem against its full-size
original, repoints the block at the new optimized attachment, and reports
progress and errors via snackbars.

Gated on window.__clientSideMediaProcessing and isClientSideMediaSupported()
so it only appears when client-side media processing is active.

Part of #79364.
…e2e flow

Add store unit tests for the optimizeExistingItem enqueue shape, its
unsupported/non-image/duplicate guards, and fetchRemoteFile success and
error paths. Extend the client-side media processing e2e spec with an
'optimize a previously uploaded image' case asserting the block repoints
to a new -optimized attachment that is no larger than the original.

Part of #79364.
@github-actions github-actions Bot added the [Package] Editor /packages/editor label Jun 24, 2026
@github-actions

github-actions Bot commented Jun 24, 2026 •

Copy link
Copy Markdown

Size Change: +1.45 kB (+0.02%)

Total Size: 7.92 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 582 kB +743 B (+0.13%)
build/scripts/upload-media/index.min.js 17 kB +708 B (+4.35%)

compressed-size-action

The optimizeExistingItem action was added without regenerating the
autogenerated API docs, causing the check-local-changes CI step to fail.
@github-actions

github-actions Bot commented Jun 25, 2026 •

Copy link
Copy Markdown

Flaky tests detected in e5f749a.
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.

🔍 Workflow run URL: https://github.com/WordPress/gutenberg/actions/runs/33421132919
📝 Reported tests:

Should save the changes in /test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js, passed after 2 failed attempts.
TimeoutError: page.waitForFunction: Timeout 10000ms exceeded.
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js:34:14
TimeoutError: locator.click: Timeout 10000ms exceeded.
Call log:
  - waiting for locator('role=button[name="Visual"i]')

    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/editor/plugins/wp-editor-meta-box.spec.js:33:55

…ze-existing-media

# Conflicts:
#	packages/editor/CHANGELOG.md
#	packages/upload-media/src/store/private-actions.ts
#	packages/upload-media/src/utils.ts
…peration resolves

Trunk's cancelItem gained additional async steps (retry scheduling,
GIF-to-video cancellation), so a fire-and-forget dispatch no longer
guarantees the caller's onError has run by the time fetchRemoteFile
settles.
@adamsilverstein adamsilverstein added [Type] Enhancement A suggestion for improvement. [Feature] Client Side Media Media processing in the browser with WASM labels Jul 2, 2026
…2e test

Trunk migrated the image block inspector to media and settings groups
(1e3ad1f), so the inspector now opens on the Content tab and the
Optimize panel on the Settings tab is no longer visible by default.
@andrewserong

andrewserong commented Jul 2, 2026 •

Copy link
Copy Markdown
Contributor

Can you share a screenshot or demo of how this looks (to aid other reviewers in assessing this)? I'm a little hesitant about how we expose UI controls for image optimisation as it's quite an advanced feature for the casual user and for much of the rest of client-side media processing we're attempting to hide or abstract this away for folks so that the user is unaware of what's happening.

If and when you're ready it'd be good to ping some designers to help guide where and how we expose this in the UI.

My leaning would be to not include this in the 7.1 cycle, as my hunch is that overall the client-side media processing feature is a good one for future uploads, and reprocessing or optimising existing images feels a bit like plugin territory (or an administrative task). But I'd be keen to hear what others think.

@adamsilverstein

Copy link
Copy Markdown
Member Author

Can you share a screenshot or demo of how this looks (to aid other reviewers in assessing this)? I'm a little hesitant about how we expose UI controls for image optimisation as it's quite an advanced feature for the casual user and for much of the rest of client-side media processing we're attempting to hide or abstract this away for folks so that the user is unaware of what's happening.

If and when you're ready it'd be good to ping some designers to help guide where and how we expose this in the UI.

My leaning would be to not include this in the 7.1 cycle, as my hunch is that overall the client-side media processing feature is a good one for future uploads, and reprocessing or optimising existing images feels a bit like plugin territory (or an administrative task). But I'd be keen to hear what others think.

I agree, this probably needs some design feedback. I've modeled it on what Pascal built for media experiments. I'd also love to explore a bulk optimization feature separately.

I'll capture some screencasts/screenshots.

@adamsilverstein

adamsilverstein commented Jul 2, 2026 •

Copy link
Copy Markdown
Member Author

I'll capture some screencasts/screenshots.

Added to the PR and Issue descriptions

@swissspidy

Copy link
Copy Markdown
Member

LGTM 👍 Nice to see some familiar code :) We can probably put it behind a flag to continue refining it.

@adamsilverstein adamsilverstein added the Needs Design Feedback Needs general design feedback. label Jul 2, 2026
@adamsilverstein

Copy link
Copy Markdown
Member Author

LGTM 👍 Nice to see some familiar code :) We can probably put it behind a flag to continue refining it.

Thanks for the canonical example! By flag do you mean making it an experiment (enabled in settings) or something else?

@swissspidy

Copy link
Copy Markdown
Member

Yes an experiment

@andrewserong

andrewserong commented Jul 3, 2026 •

Copy link
Copy Markdown
Contributor

An experiment sounds good 👍

It could be a good way to play around with other UI ideas, too. The sidebar panel idea is fairly prominent. Another option if we wanted something a little more power-user-ey could be to add a command for it, so folks can click the command palette and see it available there.

One question that I wondered while giving this another skim — is the only guard to tell if an image has already been optimized the filename? How else might we see which files are eligible... or to put the question slightly differently, how might we tell when it's beneficial to the user to run the optimization versus those times when it's of little benefit? This might be sort of the more admin UI idea (and therefore a rabbit hole)... but for image optimization I sort of crave a UI where we can see before / after and the user can drag a slider for quality, a bit like Photoshop export, etc. And possibly even see estimated file size changes and so on.

Definitely post 7.1 sort of stuff that kind of complex UI idea.

In any case, this comment is mostly me attempting to say I like the overall goal of this feature and I think there'll be lots of cool things to explore for it, so creating an experiment makes sense to me.

…ze-existing-media

# Conflicts:
#	packages/upload-media/CHANGELOG.md
@adamsilverstein

adamsilverstein commented Jul 12, 2026 •

Copy link
Copy Markdown
Member Author

An experiment sounds good 👍

It could be a good way to play around with other UI ideas, too. The sidebar panel idea is fairly prominent. Another option if we wanted something a little more power-user-ey could be to add a command for it, so folks can click the command palette and see it available there.

I like the power user command although that is a bit hidden.

One question that I wondered while giving this another skim — is the only guard to tell if an image has already been optimized the filename? How else might we see which files are eligible... or to put the question slightly differently, how might we tell when it's beneficial to the user to run the optimization versus those times when it's of little benefit?

Two cases here:

  1. an image might be missing sizes, for example if the user installs a plugin or switches themes and new sizes have been added in code - in this case the image is "broken" and some sub-sizes are not available. These we can detect automatically on the server and even provide a UI to alert users to the issue (offering an auto fix path)
  2. an image might not be taking advantage of the best format, for example a post might use JPEGs when WebP would be a more performant option. This is. more subtle decision with potential unknown side effects. For example if users try to download the images from the site and then upload the WebPs elsewhere, they may not be able to.

Reminds me of:
image


For case 1, I'm comfortable having WordPress recommend and enable auto-backfilling of missing sizes.

For case 2, I would tread much more cautiously. Maybe we can add the capability to do this in Gutenberg/Core, but implement it first in the Performance Lab plugin.

This might be sort of the more admin UI idea (and therefore a rabbit hole)... but for image optimization I sort of crave a UI where we can see before / after and the user can drag a slider for quality, a bit like Photoshop export, etc. And possibly even see estimated file size changes and so on.

Yes, this would be super cool, I know squoosh has this as well. Again, maybe this could start in the Performance Lab plugin if we made sure the right APIs were available to support that.

Definitely post 7.1 sort of stuff that kind of complex UI idea.

In any case, this comment is mostly me attempting to say I like the overall goal of this feature and I think there'll be lots of cool things to explore for it, so creating an experiment makes sense to me.

🎉 Thanks for the feedback. I'll encapsulate as an experiment for now, maybe we will wind up with several media related features we can bundle in a media section, or possibly as a single experiment.

Reviewers asked for the optimize-existing-media UI to be opt-in while
the feature is refined. Register a new 'Optimize existing media'
experiment on the Experiments screen, bridge it to the editor via
window.__experimentalOptimizeExistingMedia, and only render the
Optimize inspector panel when the experiment is enabled. The e2e test
now enables the experiment for its scope and resets it afterward.
@adamsilverstein

Copy link
Copy Markdown
Member Author

Done in 38f2ede: the Optimize panel is now gated behind a new "Optimize existing media" experiment (Settings → Experiments, Media group). The e2e test enables the experiment for its scope. Added the command palette idea to the follow-ups list.

The trunk merge brought in the tsconfig build/dev split from #81514, which
type checks this test file for the first time. registry.register now types
cleanly, so the directive is unused and fails the type check with TS2578.
@aduth

aduth commented Aug 26, 2026

Copy link
Copy Markdown
Member

Hey 👋 I wanted to give you a heads-up since this pull request adds new files containing JSX.

#80123 enables an ESLint rule that requires that files containing JSX must use the .tsx file extension. This is in line with coding guidelines expecting new code to be written as TypeScript.

What you'll need to do: You'll need to rename any new files containing JSX to use the .tsx file extension. This may also require you to address type errors that were not previously caught due to the use of the .js file extension.

This comment is automated, based on pull requests with recent activity that contain affected .js or .jsx files. But if you have any questions or if I can help with the migration in any way, please let me know and I'll do my best to help!

Trunk's react/jsx-filename-extension rule rejects JSX in .js files.
Match the sibling editor hooks by using the .jsx extension and record
the suppression alongside them.
New files containing JSX must use the .tsx extension per the coding
guidelines, so drop the react/jsx-filename-extension suppression rather
than carry it. Typing the file surfaced a bug: editEntityRecord takes
( kind, name, recordId, edits ), so the site-logo control was passing its
edits as the record ID and never repointed the logo.
…ze-existing-media

# Conflicts:
#	packages/upload-media/CHANGELOG.md
#	packages/upload-media/src/store/private-actions.ts
#	test/e2e/specs/editor/various/client-side-media-processing.spec.js
@github-actions

github-actions Bot commented Sep 15, 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: adamsilverstein <adamsilverstein@git.wordpress.org>
Co-authored-by: andrewserong <andrewserong@git.wordpress.org>
Co-authored-by: swissspidy <swissspidy@git.wordpress.org>
Co-authored-by: aduth <aduth@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: +1.35 kB (+0.02%)

Total Size: 8.69 MB

📦 View Changed
Filename Size Change
build/scripts/editor/index.min.js 573 kB +686 B (+0.12%)
build/scripts/upload-media/index.min.js 16.7 kB +667 B (+4.16%)

fedbd7b Run

⚡ Performance

Show the results

Client side metrics exclude the server response time.

front-end-block-theme

Metric e63eb38 trunk % Change
timeToFirstByte 56 ms +5.36% -3.66% 56.4 ms +5.14% -6.12% -0.71%
largestContentfulPaint 88 ms +2.27% -4.55% 88 ms +11.36% -4.55% 0%
lcpMinusTtfb 30.25 ms +21.65% -6.28% 32.6 ms +16.1% -13.5% -7.21%
wpBeforeTemplate 29.07 ms +7.02% -2.1% 28.96 ms +10.74% -1.83% 0.38%
wpTemplate 22.47 ms +2.94% -3.34% 22.64 ms +4.77% -7.64% -0.75%
wpTotal 51.97 ms +6.06% -3.44% 52.63 ms +3.88% -6.12% -1.25%
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 e63eb38 trunk % Change
timeToFirstByte 46.8 ms +7.48% -1.07% 46.3 ms +10.26% -2.7% 1.08%
largestContentfulPaint 84 ms +4.76% -2.38% 80 ms +5% -0% 5%
lcpMinusTtfb 36.5 ms +3.29% -5.75% 35 ms +3.29% -3.14% 4.29%
wpBeforeTemplate 26.77 ms +1.76% -1.2% 26.43 ms +12.22% -2.12% 1.29%
wpTemplate 16.8 ms +3.93% -2.02% 16.95 ms +4.07% -4.96% -0.88%
wpTotal 43.79 ms +4.48% -1.42% 43.21 ms +10.11% -2.5% 1.34%
wpMemoryUsage 6.44 MB +0% -0% 6.40 MB +0% -0% 0.56%
wpDbQueries 13 +0% -0% 13 +0% -0% 0%

media-processing

Metric e63eb38 trunk % Change
mediaProcessingJpeg 408.37 ms +0.66% -0.29% 405.87 ms +1.33% -1.14% 0.62%
mediaProcessingAvif 6173.28 ms +0.38% -0.07% 6215.48 ms +0.17% -0.31% -0.68%
mediaProcessingJpegToAvif 4255.07 ms +0.42% -0.29% 4307.85 ms +0.77% -0.21% -1.23%

media-upload

Metric e63eb38 trunk % Change
jpegUploadProcessing 2005.11 ms +1.11% -2.25% 1533.6 ms +29.56% -1.08% 30.75%
pngUploadProcessing 277.55 ms +5.11% -1.92% 276.03 ms +1.85% -1.16% 0.55%
largeJpegUploadProcessing 1984.22 ms +0.6% -0.89% 1985.07 ms +0.78% -1.38% -0.04%
multipleImageUploadProcessing 2131.71 ms +2.28% -2.96% 2060 ms +2.58% -14.36% 3.48%

post-editor

Metric e63eb38 trunk % Change
serverResponse 490.01 ms +0.71% -4.35% 477.57 ms +2.43% -4.65% 2.6%
firstPaint 396.12 ms +11.2% -4.57% 402.68 ms +7.39% -5.99% -1.63%
domContentLoaded 806.81 ms +3.09% -1.35% 812.31 ms +1.61% -0.7% -0.68%
loaded 807.89 ms +3.08% -1.37% 813.6 ms +1.58% -0.74% -0.7%
firstContentfulPaint 447.91 ms +6.51% -1.66% 460.71 ms +2.47% -1.11% -2.78%
firstBlock 2191.9 ms +0.85% -0.81% 2188.26 ms +1.01% -1.94% 0.17%
type 17.9 ms +4.3% -4.75% 17.18 ms +6.81% -5.94% 4.19%
typeWithoutInspector 17.85 ms +5.99% -16.3% 17.41 ms +3.62% -7.41% 2.53%
typeWithTopToolbar 24.04 ms +4.12% -8.78% 22.98 ms +1.96% -7.14% 4.61%
typeContainer 8.31 ms +3.97% -7.22% 8.05 ms +7.83% -19.38% 3.23%
focus 129.43 ms +3.01% -7.36% 120.19 ms +0.78% -6.32% 7.69%
firstFocus 268.87 ms +0% -0% 253.76 ms +0% -0% 5.95%
selectAll 423.21 ms +1.34% -6.4% 408.53 ms +3.37% -0.65% 3.59%
undo 30.22 ms +1.95% -7.64% 28.48 ms +6.95% -3.27% 6.11%
listViewOpen 81.8 ms +5.32% -6.23% 80.35 ms +9.67% -9.21% 1.8%
inserterOpen 42.94 ms +24.71% -12.72% 39.49 ms +10.13% -3.85% 8.74%
inserterHover 11.74 ms +5.96% -9.45% 11.54 ms +9.01% -14.73% 1.73%
inserterSearch 8.1 ms +12.72% -5.68% 7.91 ms +4.17% -9.61% 2.4%
loadPatterns 650.89 ms +7.78% -0.94% 636.4 ms +7.8% -2.79% 2.28%
wpTotal 480.32 ms +0.76% -4.39% 467.94 ms +2.52% -5.24% 2.65%
wpMemoryUsage 14.80 MB +0% -0% 14.77 MB +0% -0% 0.17%
wpDbQueries 55 +0% -0% 55 +0% -0% 0%

site-editor

Metric e63eb38 trunk % Change
serverResponse 381.81 ms +6.33% -1.6% 403.84 ms +0.92% -3.77% -5.46%
firstPaint 401.92 ms +7.25% -4.25% 446.96 ms +4.8% -10.33% -10.08%
domContentLoaded 833.87 ms +0.29% -1.6% 830.78 ms +0.73% -0.85% 0.37%
loaded 834.87 ms +0.27% -1.56% 831.89 ms +0.71% -0.87% 0.36%
firstContentfulPaint 466.94 ms +0.87% -2.19% 466.39 ms +2.14% -1.05% 0.12%
firstBlock 2467.95 ms +9.2% -0.43% 2458.87 ms +0.24% -1.38% 0.37%
type 18.61 ms +5.59% -15.48% 17.9 ms +4.69% -11.96% 3.97%
navigate 115.44 ms +1.99% -6.98% 110.55 ms +8.55% -1.98% 4.42%
loadPatterns 1364.56 ms +5.27% -16.8% 1375.72 ms +5.3% -6.37% -0.81%
loadPages 937.2 ms +1.6% -3.37% 924.42 ms +4.12% -1.19% 1.38%
wpTotal 372.11 ms +6.31% -1.74% 394.12 ms +0.93% -3.88% -5.58%
wpMemoryUsage 12.84 MB +0% -0% 12.80 MB +0% -0% 0.29%
wpDbQueries 45 +0% -0% 45 +0% -0% 0%

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

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).toBeVisible() failed

Locator: getByRole('listbox', { name: 'Search results' })
Expected: visible
Timeout: 5000ms
Error: element(s) not found

Call log:
  - Expect "toBeVisible" getByRole('listbox', { name: 'Search results' }) with timeout 5000ms
  - waiting for getByRole('listbox', { name: 'Search results' })

    at LinkControl.useLinkControlSearch (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:423:33)
    at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/navigation-sidebar-list-view.spec.js:179:3
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-a65bec4b-93f7-465b-afe2-4233bf7af8cf" data-block="a65bec4b-93f7-465b-afe2-4233bf7af8cf" 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

fedbd7b Run

adamsilverstein and others added 7 commits September 15, 2026 09:01
Vitest runs with `globals: false`, so the test helpers have to be imported
rather than picked up from the environment as they were under Jest.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtZdDWdC33cNHfY4U238A5
`jest.Mock` was a namespace type; Vitest exports `Mock` as a regular type,
so it has to be imported rather than reached through the `vi` object.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtZdDWdC33cNHfY4U238A5
The conventions validator requires it, and it type checks the factory against
the real module, so each one is cast the way the other upload-media tests do.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01RtZdDWdC33cNHfY4U238A5
…rdPress/gutenberg into feature/79364-optimize-existing-media
…ze-existing-media

# Conflicts:
#	packages/upload-media/CHANGELOG.md
#	packages/upload-media/src/store/actions.ts
Trunk upgraded wp-prettier, which changes the indentation of chained
object arguments and the spacing inside type-only import() calls.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01KhPEP5AwC5d1HyshWG5Bya
@aduth

aduth commented Sep 18, 2026

Copy link
Copy Markdown
Member

Hey 👋 I wanted to give you a heads-up since this pull request is affected by recent validation changes for changelog files.

#83043 adds additional validation for changelog files. You'll note that this pull request is currently failing a "Required changes from trunk" check.

What you'll need to do: You will need to either rebase or merge the latest code from trunk. In addition, a cursory review of open pull requests identified this pull request as potentially failing under the new validation checks. You will want to double-check that any changes to CHANGELOG.md files follow the Maintaining Changelogs guidance, which has been improved as part of these recent changes.

adamsilverstein and others added 3 commits September 18, 2026 09:02
The 15.0.0 release renamed the `## Unreleased` heading it was written
under, stranding this PR's entry inside the published 14.51.0 section.
The "Validate CHANGELOG structure" check requires an open PR's entry to
sit under `## Unreleased`, so recreate a `New Features` subsection there
and move the entry into it.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XymJGmRuNKwf8srrtsrcLR
Bring the branch current with trunk. Two conflicts: the upload-media
changelog, where trunk published 0.41.0 and this PR's entry stays under
Unreleased, and the private-actions utils import, which keeps both this
branch's fetchFile and trunk's getFileBasename.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01GqepyjmFSryBt88j6f6ubY
Trunk removed them as unused (#85094); this branch's fetchFile and
optimizeExistingItem still need them. Also adapt the optimize hook to
trunk's typed block-editor entry point and @wordpress/ui Spinner.
@fcoveram

fcoveram commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

I tried the flow and I'm not sure what's the value it brings to user when editing a document.

The feature suits better in flows to manage the whole library or settings at the document level, but this image-level optimization is for power users that are aware of what the optimization does and how that impacts the site.

@adamsilverstein

Copy link
Copy Markdown
Member Author

I tried the flow and I'm not sure what's the value it brings to user when editing a document.

The feature suits better in flows to manage the whole library or settings at the document level, but this image-level optimization is for power users that are aware of what the optimization does and how that impacts the site.

Fair point @fcoveram - this is a bit of a power user feature, probably plugin territory. I'll see if we can add it to the Performance Lab plugin. For core, maybe something to consider for the media library rebuild.

@adamsilverstein
adamsilverstein marked this pull request as draft November 10, 2026 13:49
# Conflicts:
#	packages/editor/CHANGELOG.md
#	packages/upload-media/CHANGELOG.md
#	packages/upload-media/src/utils.ts

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

[Feature] Client Side Media Media processing in the browser with WASM Needs Design Feedback Needs general design feedback. [Package] Editor /packages/editor [Type] Enhancement A suggestion for improvement.

Projects

Status: 🔎 Needs Review

Development

Successfully merging this pull request may close these issues.

Optimize previously uploaded media

5 participants