diff --git a/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php b/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
index 90ab5185fd..b283d9fab5 100644
|
a
|
b
|
class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { |
| 106 | 106 | |
| 107 | 107 | if ( ! empty( $files ) ) { |
| 108 | 108 | $file = $this->upload_from_file( $files, $headers ); |
| | 109 | $name = $files['file']['name']; |
| | 110 | $ext = pathinfo( $name, PATHINFO_EXTENSION ); |
| | 111 | $name = wp_basename( $name, ".$ext" ); |
| 109 | 112 | } else { |
| 110 | 113 | $file = $this->upload_from_data( $request->get_body(), $headers ); |
| | 114 | $name = preg_replace( '/\.[^.]+$/', '', basename( $file ) ); |
| 111 | 115 | } |
| 112 | 116 | |
| 113 | 117 | if ( is_wp_error( $file ) ) { |
| 114 | 118 | return $file; |
| 115 | 119 | } |
| 116 | 120 | |
| 117 | | $name = basename( $file['file'] ); |
| 118 | | $name_parts = pathinfo( $name ); |
| 119 | | $name = trim( substr( $name, 0, -( 1 + strlen( $name_parts['extension'] ) ) ) ); |
| 120 | | |
| 121 | 121 | $url = $file['url']; |
| 122 | 122 | $type = $file['type']; |
| 123 | 123 | $file = $file['file']; |
| … |
… |
class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller { |
| 140 | 140 | $attachment->guid = $url; |
| 141 | 141 | |
| 142 | 142 | if ( empty( $attachment->post_title ) ) { |
| 143 | | $attachment->post_title = preg_replace( '/\.[^.]+$/', '', basename( $file ) ); |
| | 143 | $attachment->post_title = sanitize_text_field( $name ); |
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // $post_parent is inherited from $attachment['post_parent']. |