Make WordPress Core

Changes between Initial Version and Version 2 of Ticket #64804


Ignore:
Timestamp:
03/05/2026 05:50:16 PM (2 months ago)
Author:
westonruter
Comment:

Legend:

Unmodified
Added
Removed
Modified
  • Ticket #64804

    • Property Keywords has-unit-tests added
  • Ticket #64804 – Description

    initial v2  
    33Many 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.
    44
    5 ### Proposed solution
     5=== Proposed solution ===
    66
    77Add a `POST /wp/v2/media/{id}/finalize` REST API endpoint to `WP_REST_Attachments_Controller`. This endpoint:
     
    1414The 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.
    1515
    16 ### How it works
     16=== How it works ===
    1717
    1818The 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:
    1919
    20 ```php
     20{{{#!php
     21<?php
    2122add_filter( 'wp_generate_attachment_metadata', function( $metadata, $attachment_id, $context ) {
    2223    if ( 'update' === $context ) {
     
    2627    return $metadata;
    2728}, 10, 3 );
    28 ```
     29}}}
    2930
    30 ### Permissions
     31=== Permissions ===
    3132
    3233The endpoint reuses `edit_media_item_permissions_check()`, consistent with the existing `sideload` and `edit` endpoints. A user must have permission to edit the attachment.
    3334
    34 ### Related
     35=== Related ===
    3536
    36 - Gutenberg PR (hooks + JS pipeline): https://github.com/WordPress/gutenberg/pull/74913
    37 - Gutenberg issue: https://github.com/WordPress/gutenberg/issues/74358
    38 - Core PR: https://github.com/WordPress/wordpress-develop/pull/11168
    39 - Parent ticket (client-side media processing): https://core.trac.wordpress.org/ticket/62243
    40 - Previous Core backport PR: https://github.com/WordPress/wordpress-develop/pull/10868
     37* 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