close
Skip to content

Media: Re-introduce client-side media processing feature#11324

Open
adamsilverstein wants to merge 12 commits into
WordPress:trunkfrom
adamsilverstein:reintroduce-client-side-media
Open

Media: Re-introduce client-side media processing feature#11324
adamsilverstein wants to merge 12 commits into
WordPress:trunkfrom
adamsilverstein:reintroduce-client-side-media

Conversation

@adamsilverstein
Copy link
Copy Markdown
Member

@adamsilverstein adamsilverstein commented Mar 20, 2026

Summary

  • Reverts the removal in [62081] now that WordPress 7.1 has forked
  • Restores all PHP functions, REST API endpoints, cross-origin isolation infrastructure, VIPS script module handling, build configuration, and associated tests
  • 14 files restored, ~1,625 lines

Test plan

  • CI passes (coding standards, PHPUnit, JS tests)
  • Verify client-side media processing functions are restored in wp-includes/media.php
  • Verify REST API endpoints for attachments are restored
  • Verify cross-origin isolation test suite passes
  • Verify VIPS script module registration is restored

Trac ticket: https://core.trac.wordpress.org/ticket/64919

Props adamsilverstein, jorbin, westonruter.
See #64906.

@github-actions
Copy link
Copy Markdown

github-actions Bot commented Mar 20, 2026

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

Unlinked Accounts

The following contributors have not linked their GitHub and WordPress.org accounts: @1178653+wordpress-develop-pr-bot[bot]@users.noreply.github.com.

Contributors, please read how to link your accounts to ensure your work is properly credited in WordPress releases.

Core Committers: Use this line as a base for the props when committing in SVN:

Props adamsilverstein, westonruter.

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

Reverts the removal in [62081] now that WordPress 7.1 has forked. Restores all PHP functions, REST API endpoints, cross-origin isolation infrastructure, VIPS script module handling, build configuration, and associated tests.

Props adamsilverstein, jorbin.
See #64906.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@github-actions
Copy link
Copy Markdown

Test using WordPress Playground

The changes in this pull request can previewed and tested using a WordPress Playground instance.

WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Some things to be aware of

  • All changes will be lost when closing a tab with a Playground instance.
  • All changes will be lost when refreshing the page.
  • A fresh instance is created each time the link below is clicked.
  • Every time this pull request is updated, a new ZIP file containing all changes is created. If changes are not reflected in the Playground instance,
    it's possible that the most recent build failed, or has not completed. Check the list of workflow runs to be sure.

For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation.

Test this pull request with WordPress Playground.

@adamsilverstein
Copy link
Copy Markdown
Member Author

adamsilverstein commented May 22, 2026

This worked well in my testing. After this PR, the client side media worked just as it was working before the revert.

7.1 is now open for commits, see https://make.wordpress.org/core/2026/05/20/commence-operation-wp-7-1/

As soon as I commit this, I plan to work to backport code for a series of improvements that have already merged to Gutenberg. These backports were blocked because the code was missing from core.

Here is a complete list of PRs to backport:

1. Merged PRs — backports ready to merge (once restored)

These have landed on Gutenberg trunk and touch reverted Core code, so they are blocked only by
the restore. All merged after the 2026-03-20 removal.

PR Merged PHP touched Core backport PR Status / notes
#76731 — Add HEIC support using platform capabilities 2026-04-20 class-gutenberg-rest-attachments-controller.php, load.php (HEIC companion-file handling) wordpress-develop#11323 — OPEN, drafted Core PR also bundles #78128. Blocked by revert.
#78128 — Guard gutenberg_delete_heic_companion_file() 2026-05-12 load.php Folded into wordpress-develop#11323 Hardening fix on top of #76731; rides the same Core PR.
#74903 — Add dimension validation to sideload endpoint 2026-05-15 class-gutenberg-rest-attachments-controller.php wordpress-develop#11100 — OPEN, drafted Validates dimensions on the sideload route. Blocked by revert.
#75888 — Enable concurrent sideload uploads 2026-04-20 class-gutenberg-rest-attachments-controller.php adamsilverstein/wordpress-develop#48 — OPEN, drafted Carries the Needs PHP backport label. No backport-changelog entry; open a Core PR.
#77036 — Deduplicate client-side image sizes with matching dimensions 2026-04-21 class-gutenberg-rest-attachments-controller.php adamsilverstein/wordpress-develop#49 — OPEN, drafted (stacked on #48) No backport-changelog entry and no backport label. Open a Core PR.
#77565 — Declare convert_format as boolean arg on sideload route 2026-04-23 class-gutenberg-rest-attachments-controller.php adamsilverstein/wordpress-develop#50 — OPEN, drafted (stacked on #49; tests only, controller change already in core) No backport-changelog entry and no backport label. Open a Core PR.

2. Open PRs — draft the backport, keep it in draft until the GB PR merges

These touch reverted Core code but the Gutenberg PR is still open. Draft the Core PR if useful,
but keep it in draft until the Gutenberg PR lands (and the feature is restored).

PR PHP touched Core backport Status / notes
#78410 — Add animated GIF to video conversion via mediabunny animated-gif-to-video.php (new render-swap filter), class-gutenberg-rest-attachments-controller.php (animated-video / animated-video-poster sideload), client-assets.php, load.php None yet Carries Needs PHP backport. REST sideload roles depend on the CSM controller → blocked by revert. The editor also does GIF→video block-switching (core/video GIF variation); deletes attached files on media delete.
#77584 — Lazy-load JPEG XL (JXL) WASM on demand class-gutenberg-rest-attachments-controller.php (finalize_item / sideload_item), load.php (adds JXL upload mimes; renames gutenberg_delete_heic_companion_filegutenberg_delete_preserved_original_companion_file) None yet Reclassified: previously listed as JS-only, but it now touches the CSM controller and load.php → blocked by revert.
#78404 — Send Document-Isolation-Policy header on the site preview frame load.php (cross-origin-isolation setup) None yet Depends on the COI scaffolding the revert removed → blocked. Related to #76662.
#76662 — Broaden DIP header scope to all admin pages load.php (cross-origin-isolation setup) None yet Same COI scaffolding as #78404 → blocked. The two overlap; reconcile before backporting.
#76227 — WIP: Disable client-side media processing for non-Chromium browsers lib/compat/wordpress-7.0/media.php (feature gate), load.php (Chromium version detection) None yet WIP. Reassess once finalized; the Chromium-detection logic may or may not be Core-bound.

3. Watch list — related, but not blocked by the revert

PR State Why it's separate
#78420 — Return filtered wp_editor_set_quality in upload response OPEN Core backport drafted: wordpress-develop#11856 (OPEN). The image_quality field is added to the base WP_REST_Attachments_Controller schema / prepare_item_for_response, which exists in Core regardless of the revert — so not blocked by the restore. As an open PR, keep #11856 in draft until #78420 merges. Still waiting on a Trac ticket (core tests use placeholder @ticket 64906; replace once posted).
#75793 — Move image output format filtering to upload response MERGED Merged 2026-04-23 with the old No Core Sync Required bypass label. It does touch the CSM controller + load.php, so it likely owes a real Core backport once the feature is restored — reassess and open one.

Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/media.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php Outdated
Comment thread src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php Outdated
adamsilverstein and others added 2 commits May 22, 2026 14:27
Co-authored-by: Weston Ruter <westonruter@gmail.com>
The client-side media processing code originally targeted 7.0.0 but was
removed before release in [62081]. Now that the feature is being
re-introduced for 7.1, update the restored docblocks in media.php and the
attachments REST controller to reflect the version the code actually ships in.

Pre-existing 7.0.0 docblocks unrelated to the revert (fetchpriority support
and the attachment filename/filesize helpers) are left unchanged.

Addresses review feedback on WordPress#11324
Every entry in the $cross_origin_tag_attributes map was flagged `false`, so
the `if ( $is_srcset )` branch was never reachable; PHPStan reported it as
always false. No tag enables srcset processing, and the cross-origin
isolation tests assert that srcset-based cross-origin URLs are deliberately
left untouched (img is not handled and link only checks href).

Drop the unreachable branch and simplify the attribute map to a plain list
of attributes. Behavior is unchanged and the full cross-origin isolation
test suite still passes.

Addresses review feedback on WordPress#11324
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants