Make WordPress Core


Ignore:
Timestamp:
10/20/2026 05:02:48 AM (14 hours ago)
Author:
adamsilverstein
Message:

Media: Enable client-side uploads in the Media Library and modal.

Enable client-side media processing for Uploads from the Media Library grid, the Add New Media File screen and the media modal in the block editor (in supported browsers).

These screens now use the same pipeline as block editor uploads: the original is uploaded through the REST API, sub-sizes are generated in the browser and sideloaded, then the attachment is finalized. wp_set_up_cross_origin_isolation() now also isolates the Media Library grid and the Add New Media File screen using Document Isolation Policy. Uploads huse the client-side processing still use the existing progress, tile and error UI.

When client-side processing is disabled, uploads fall back to the classic flow unchanged. Audio files, uploaders that do not post attachments, and JPEG/PNG files while plupload resizing is enabled also stay on the classic path, and a HEIC the browser cannot decode is handed to the server when its image editor supports HEIC. The Customizer, Site Icon picker and classic editor are not isolated and keep classic uploads.

See ​https://github.com/WordPress/gutenberg/issues/82409.

Props adamsilverstein, westonruter, andrewserong, sanayasir, arkaprabhachowdhury, logicrays.
Fixes #65661. See #66220.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/wp-includes/rest-api/class-wp-rest-server.php

    r64527 r64588  
    14661466                // Add media processing settings for users who can upload files.
    14671467                if ( wp_is_client_side_media_processing_enabled() && current_user_can( 'upload_files' ) ) {
    1468                         // Image sizes keyed by name for client-side media processing.
    1469                         $available['image_sizes'] = array();
    1470                         foreach ( wp_get_registered_image_subsizes() as $name => $size ) {
    1471                                 $available['image_sizes'][ $name ] = $size;
    1472                         }
    1473 
    1474                         /** This filter is documented in wp-admin/includes/image.php */
    1475                         $available['image_size_threshold'] = (int) apply_filters( 'big_image_size_threshold', 2560, array( 0, 0 ), '', 0 );
    1476 
    1477                         /** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */
    1478                         $available['image_strip_meta'] = (bool) apply_filters( 'image_strip_meta', true );
    1479 
    1480                         /*
    1481                          * On the server, this filter receives the decoded image's actual bit depth.
    1482                          * The client path never decodes the image on the server, so the filter is
    1483                          * applied with 16 (the maximum depth the client encoder can produce) as
    1484                          * both the value and the current depth. The client caps its output bit
    1485                          * depth at the filtered value, so a plugin lowering it (e.g. to 8) takes
    1486                          * effect on client-generated images too.
    1487                          */
    1488                         /** This filter is documented in wp-includes/class-wp-image-editor-imagick.php */
    1489                         $available['image_max_bit_depth'] = (int) apply_filters( 'image_max_bit_depth', 16, 16 );
    1490 
    1491                         /**
    1492                          * Filters whether client-side media processing preserves animation in image sub-sizes.
    1493                          *
    1494                          * By default, sub-sizes of animated GIF and WebP images retain animation,
    1495                          * including cropped sizes. Return false to generate static sub-sizes using
    1496                          * only the first frame, reducing processing time in the browser.
    1497                          *
    1498                          * This setting applies only to client-side media processing. Server-side
    1499                          * processing continues to generate static sub-sizes.
    1500                          *
    1501                          * @since 7.2.0
    1502                          *
    1503                          * @param bool $generate_animated_image_subsizes Whether to preserve animation in image sub-sizes.
    1504                          *                                               Default true.
    1505                          */
    1506                         $available['generate_animated_image_subsizes'] = (bool) apply_filters( 'wp_generate_animated_image_subsizes', true );
     1468                        $available = array_merge( $available, _wp_get_client_side_media_image_settings() );
    15071469                }
    15081470
Note: See TracChangeset for help on using the changeset viewer.