Changeset 62616 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
- Timestamp:
- 07/01/2026 07:05:12 PM (3 days ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r62609 r62616 24 24 */ 25 25 protected $allow_batch = false; 26 27 /** 28 * Image size token for the source-format original preserved alongside a 29 * client-generated derivative (e.g. the HEIC file kept next to its JPEG). 30 * 31 * Used both in the `/sideload` route schema and when dispatching the 32 * sideloaded file to its metadata key, so the two never drift apart. 33 * 34 * @since 7.1.0 35 * @var string 36 */ 37 const IMAGE_SIZE_SOURCE_ORIGINAL = 'source_original'; 38 39 /** 40 * Metadata key holding the basename of the source-format original. 41 * 42 * Deliberately specific so it never collides with the generic `original` 43 * or `original_image` keys other flows write to. 44 * 45 * @since 7.1.0 46 * @var string 47 */ 48 const META_KEY_SOURCE_IMAGE = 'source_image'; 26 49 27 50 /** … … 99 122 $valid_sizes[] = 'scaled'; 100 123 $valid_sizes[] = 'full'; 124 // Source-format original (e.g. the HEIC kept alongside its JPEG derivative). 125 $valid_sizes[] = self::IMAGE_SIZE_SOURCE_ORIGINAL; 101 126 102 127 $items = is_string( $value ) ? array( $value ) : ( is_array( $value ) ? $value : null ); … … 328 353 } 329 354 355 /* 356 * Always allow still HEIC/HEIF uploads through even if the server's 357 * image editor doesn't support them. The client-side canvas fallback 358 * handles processing using the browser's native HEVC decoder. 359 * 360 * The '-sequence' variants (multi-frame Live Photos) are deliberately 361 * excluded: neither the server nor the browser fallback can process 362 * them yet, so they should fall through to the standard unsupported 363 * mime-type error rather than be stored unprocessable. 364 */ 365 $still_heic_mime_types = array( 'image/heic', 'image/heif' ); 366 367 if ( 368 $prevent_unsupported_uploads && 369 ! empty( $files['file']['type'] ) && 370 in_array( $files['file']['type'], $still_heic_mime_types, true ) 371 ) { 372 $prevent_unsupported_uploads = false; 373 } 374 330 375 // If the upload is an image, check if the server can handle the mime type. 331 376 if ( … … 1459 1504 * @param array $headers HTTP headers from the request. 1460 1505 * @param string|null $time Optional. Time formatted in 'yyyy/mm'. Default null. 1461 * @return array |WP_Error Data from wp_handle_sideload().1506 * @return array{ file: non-empty-string, url: non-empty-string, type: non-empty-string }|WP_Error Data from wp_handle_sideload(). 1462 1507 */ 1463 1508 protected function upload_from_data( $data, $headers, $time = null ) { … … 1679 1724 * @param array $headers HTTP headers from the request. 1680 1725 * @param string|null $time Optional. Time formatted in 'yyyy/mm'. Default null. 1681 * @return array |WP_Error Data from wp_handle_upload().1726 * @return array{ file: non-empty-string, url: non-empty-string, type: non-empty-string }|WP_Error Data from wp_handle_upload(). 1682 1727 */ 1683 1728 protected function upload_from_file( $files, $headers, $time = null ) { … … 2174 2219 } elseif ( 'original' === $image_size ) { 2175 2220 $sub_size_data['file'] = wp_basename( $path ); 2221 } elseif ( self::IMAGE_SIZE_SOURCE_ORIGINAL === $image_size ) { 2222 /* 2223 * Source-format original (e.g. the HEIC kept next to its JPEG 2224 * derivative). Record the filename so finalize_item can store it 2225 * under the dedicated source-image meta key. 2226 */ 2227 $sub_size_data['file'] = wp_basename( $path ); 2176 2228 } elseif ( 'scaled' === $image_size ) { 2177 2229 // Record the current attached file as the original. … … 2329 2381 if ( 'original' === $image_size ) { 2330 2382 $metadata['original_image'] = $sub_size['file']; 2383 } elseif ( self::IMAGE_SIZE_SOURCE_ORIGINAL === $image_size ) { 2384 /* 2385 * Source-format original: stored under its own meta key so the 2386 * scaled-sideload flow (which writes 'original_image') cannot 2387 * clobber it. 'original_image' keeps pointing at the 2388 * web-viewable JPEG derivative. Cleanup on attachment delete 2389 * is handled by wp_delete_attachment_files(). 2390 */ 2391 $metadata[ self::META_KEY_SOURCE_IMAGE ] = $sub_size['file']; 2331 2392 } elseif ( 'scaled' === $image_size ) { 2332 2393 if ( ! empty( $sub_size['original_image'] ) ) {
Note:
See TracChangeset
for help on using the changeset viewer.
![(please configure the [header_logo] section in trac.ini)](/chrome/site/your_project_logo.png)