Changes between Initial Version and Version 2 of Ticket #64804
- Timestamp:
- 03/05/2026 05:50:16 PM (2 months ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Ticket #64804
- Property Keywords has-unit-tests added
-
Ticket #64804 – Description
initial v2 3 3 Many plugins rely on this filter to post-process uploads — for example, adding watermarks, syncing to a CDN, generating custom image sizes, or updating external indexes. When client-side processing is active, these plugins silently stop working because the filter never fires. 4 4 5 ### Proposed solution 5 === Proposed solution === 6 6 7 7 Add a `POST /wp/v2/media/{id}/finalize` REST API endpoint to `WP_REST_Attachments_Controller`. This endpoint: … … 14 14 The endpoint is only registered when `wp_is_client_side_media_processing_enabled()` returns `true`, so it has zero impact on sites not using client-side processing. 15 15 16 ### How it works 16 === How it works === 17 17 18 18 The client-side media pipeline calls this endpoint after all operations (upload, thumbnail sideloads, scaled image sideload) are complete. No new hooks are needed — the existing `wp_generate_attachment_metadata` filter is reused. Plugins that already hook into this filter will work without modification; they can distinguish client-side finalization by checking the `$context` parameter: 19 19 20 ```php 20 {{{#!php 21 <?php 21 22 add_filter( 'wp_generate_attachment_metadata', function( $metadata, $attachment_id, $context ) { 22 23 if ( 'update' === $context ) { … … 26 27 return $metadata; 27 28 }, 10, 3 ); 28 ``` 29 }}} 29 30 30 ### Permissions 31 === Permissions === 31 32 32 33 The endpoint reuses `edit_media_item_permissions_check()`, consistent with the existing `sideload` and `edit` endpoints. A user must have permission to edit the attachment. 33 34 34 ### Related 35 === Related === 35 36 36 -Gutenberg PR (hooks + JS pipeline): https://github.com/WordPress/gutenberg/pull/7491337 -Gutenberg issue: https://github.com/WordPress/gutenberg/issues/7435838 -Core PR: https://github.com/WordPress/wordpress-develop/pull/1116839 - Parent ticket (client-side media processing): https://core.trac.wordpress.org/ticket/6224340 -Previous Core backport PR: https://github.com/WordPress/wordpress-develop/pull/1086837 * Gutenberg PR (hooks + JS pipeline): https://github.com/WordPress/gutenberg/pull/74913 38 * Gutenberg issue: https://github.com/WordPress/gutenberg/issues/74358 39 * Core PR: https://github.com/WordPress/wordpress-develop/pull/11168 40 * Parent ticket (client-side media processing): #62243 41 * Previous Core backport PR: https://github.com/WordPress/wordpress-develop/pull/10868