diff --git a/wp-admin/includes/image.php b/wp-admin/includes/image.php
index 6e2b5f1..f17a1f2 100644
|
a
|
b
|
function wp_generate_attachment_metadata( $attachment_id, $file ) { |
| 106 | 106 | $metadata = array(); |
| 107 | 107 | |
| 108 | 108 | if ( preg_match( '!^image/!', get_post_mime_type( $attachment_id ) ) ) { |
| 109 | | $imagesize = getimagesize( $file ); |
| 110 | | $metadata['width'] = $imagesize[0]; |
| 111 | | $metadata['height'] = $imagesize[1]; |
| | 109 | // Skip dimension checks for SVG since they are vector-based. |
| | 110 | $type = wp_check_filetype( $file ); |
| | 111 | if ( isset( $type['ext'] ) && $type['ext'] === 'svg' ) { |
| | 112 | $metadata['width'] = 0; |
| | 113 | $metadata['height'] = 0; |
| | 114 | } else { |
| | 115 | $imagesize = @getimagesize( $file ); |
| | 116 | if ( $imagesize ) { |
| | 117 | $metadata['width'] = $imagesize[0]; |
| | 118 | $metadata['height'] = $imagesize[1]; |
| | 119 | } |
| | 120 | } |
| 112 | 121 | } |
| 113 | 122 | |
return apply_filters( 'wp_generate_attachment_metadata', $metadata, $attachment_id );
diff --git a/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
index 5d3f5f4..7f31a8c 100644
|
a
|
b
|
class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { |
| 691 | 691 | $media_details['sizes'] = array(); |
| 692 | 692 | } |
| 693 | 693 | |
| | 694 | // Ensure SVGs don’t include invalid width/height in REST responses. |
| | 695 | if ( isset( $response->data['mime_type'] ) && $response->data['mime_type'] === 'image/svg+xml' ) { |
| | 696 | unset( $media_details['sizes'] ); |
| | 697 | unset( $media_details['height'] ); |
| | 698 | unset( $media_details['width'] ); |
| | 699 | } |
| | 700 | |
| 694 | 701 | $response->data['media_details'] = $media_details; |
| 695 | 702 | |
| 696 | 703 | return $response; |