Media: Sideload and clean up the web-safe companion of a transcoded video upload - #13323
Media: Sideload and clean up the web-safe companion of a transcoded video upload#13323adamsilverstein wants to merge 1 commit into
Conversation
|
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 Core Committers: Use this line as a base for the props when committing in SVN: 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.
fd901f3 to
cc116cc
Compare
Test using WordPress PlaygroundThe 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
For more details about these limitations and more, check out the Limitations page in the WordPress Playground documentation. |
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:
optimized_videocompanion size, and only for that size. Every other size still needs an image or PDF parent.optimized_videometadata key on finalize, and include it in the names a request is allowed to store.wp_delete_attachment_files().wp_video_transcoding_keep_originalfilter (defaulttrue) on the REST index asvideo_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 tooptimized_videoon the Gutenberg side to match this backport.Testing
npm run test:php -- --filter 'Tests_Media_wpDeleteAttachmentOptimizedVideo|optimized_video|test_get_index_should'AI Use
Code and description both written with 🤖 Claude Code. I will review and test.