Skip to content

Media: Sideload and clean up the web-safe companion of a transcoded video upload - #13323

Open
adamsilverstein wants to merge 1 commit into
WordPress:trunkfrom
adamsilverstein:add/video-transcoding-companion
Open

Media: Sideload and clean up the web-safe companion of a transcoded video upload#13323
adamsilverstein wants to merge 1 commit into
WordPress:trunkfrom
adamsilverstein:add/video-transcoding-companion

Conversation

@adamsilverstein

@adamsilverstein adamsilverstein commented Aug 31, 2026

Copy link
Copy Markdown
Member

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

Backport of the PHP from WordPress/gutenberg#79375. Follow up to #12005 / [62623], which added the animated GIF video companions this builds on.

When client-side media processing is enabled, the editor transcodes an uploaded video that is not already web-safe to MP4/WebM in the browser and sideloads the result as a companion of the original video attachment, which stays the attachment. This adds the server side of that flow:

  • Accept a video attachment as the sideload parent for the new optimized_video companion size, and only for that size. Every other size still needs an image or PDF parent.
  • Record the companion under the optimized_video metadata key on finalize, and include it in the names a request is allowed to store.
  • Delete the companion alongside the attachment in wp_delete_attachment_files().
  • Expose a wp_video_transcoding_keep_original filter (default true) on the REST index as video_keep_original, and preload it with the other media processing settings.

Note: the Gutenberg PR originally used optimized-video (hyphen) for the size token. Every other special size uses underscores, so the token was renamed to optimized_video on the Gutenberg side to match this backport.

Testing

  • npm run test:php -- --filter 'Tests_Media_wpDeleteAttachmentOptimizedVideo|optimized_video|test_get_index_should'
  • All new tests were confirmed to fail before the source changes and pass after.

AI Use

Code and description both written with 🤖 Claude Code. I will review and test.

@github-actions

Copy link
Copy Markdown

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.

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

Props adamsilverstein.

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

…ideo upload.

Add server-side support for the client-side video transcoding flow. When client-side media processing is enabled, the editor transcodes an uploaded video that is not already web-safe to MP4/WebM in the browser and sideloads the result as a companion of the original video attachment, which remains the attachment itself.

- Accept a video attachment as the sideload parent for the new `optimized_video` companion size, and only for that size; every other size still requires an image or PDF parent.
- Record the companion under the `optimized_video` attachment metadata key on finalize, and treat it as a name the request is allowed to store.
- Delete the companion file alongside the attachment in `wp_delete_attachment_files()`.
- Expose the new `wp_video_transcoding_keep_original` filter (default `true`) on the REST API index as `video_keep_original`, so the editor knows whether to keep the original upload or transcode before uploading, and preload it with the other media processing settings.

See WordPress/gutenberg#79375.
@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.

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.

1 participant