Parent Issue
Part of #74333
Related trac ticket: https://core.trac.wordpress.org/ticket/64677
Context
In WordPress/wordpress-develop#10868 (Editor: PHP backports for Client Side Media), the image_editor_output_format filter is currently applied in the REST API index (get_index) by iterating over a list of possible input MIME types with an empty $output_formats array and no $filename parameter. As @westonruter pointed out, this doesn't match how wp_get_image_editor_output_format() normally applies the filter — it passes the actual filename and a pre-populated default mapping.
Problem
The current approach:
- Passes an empty array as the default value instead of the normal default mapping
- Does not supply a
$filename parameter to the filter
- Re-filters the same
$output_formats variable across iterations, accumulating results in a way that doesn't match the server-side behavior
- Is applied generically rather than per-upload, so plugins can't make decisions based on the actual input file
Proposed Solution
Move the image_editor_output_format logic from the REST API index response into the initial image upload response. This is already the pattern used for EXIF rotation data in client-side media processing.
Benefits:
- The actual input filename and MIME type will be available, so the filter operates just like it does on the server side
- Plugins that hook into
image_editor_output_format will receive meaningful parameters
- Keeps per-file processing logic in the upload response where it belongs
References
Parent Issue
Part of #74333
Related trac ticket: https://core.trac.wordpress.org/ticket/64677
Context
In WordPress/wordpress-develop#10868 (Editor: PHP backports for Client Side Media), the
image_editor_output_formatfilter is currently applied in the REST API index (get_index) by iterating over a list of possible input MIME types with an empty$output_formatsarray and no$filenameparameter. As @westonruter pointed out, this doesn't match howwp_get_image_editor_output_format()normally applies the filter — it passes the actual filename and a pre-populated default mapping.Problem
The current approach:
$filenameparameter to the filter$output_formatsvariable across iterations, accumulating results in a way that doesn't match the server-side behaviorProposed Solution
Move the
image_editor_output_formatlogic from the REST API index response into the initial image upload response. This is already the pattern used for EXIF rotation data in client-side media processing.Benefits:
image_editor_output_formatwill receive meaningful parametersReferences