Changeset 60084 for trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
- Timestamp:
- 03/25/2025 02:04:47 PM (3 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php
r58865 r60084 134 134 array( 'status' => rest_authorization_required_code() ) 135 135 ); 136 } 137 $files = $request->get_file_params(); 138 139 /** 140 * Filter whether the server should prevent uploads for image types it doesn't support. Default true. 141 * 142 * Developers can use this filter to enable uploads of certain image types. By default image types that are not 143 * supported by the server are prevented from being uploaded. 144 * 145 * @since 6.8.0 146 * 147 * @param bool $check_mime Whether to prevent uploads of unsupported image types. 148 * @param string|null $mime_type The mime type of the file being uploaded (if available). 149 */ 150 $prevent_unsupported_uploads = apply_filters( 'wp_prevent_unsupported_mime_type_uploads', true, isset( $files['file']['type'] ) ? $files['file']['type'] : null ); 151 152 // If the upload is an image, check if the server can handle the mime type. 153 if ( 154 $prevent_unsupported_uploads && 155 isset( $files['file']['type'] ) && 156 str_starts_with( $files['file']['type'], 'image/' ) 157 ) { 158 // Check if the image editor supports the type. 159 if ( ! wp_image_editor_supports( array( 'mime_type' => $files['file']['type'] ) ) ) { 160 return new WP_Error( 161 'rest_upload_image_type_not_supported', 162 __( 'The web server cannot generate responsive image sizes for this image. Convert it to JPEG or PNG before uploading.' ), 163 array( 'status' => 400 ) 164 ); 165 } 136 166 } 137 167
Note: See TracChangeset
for help on using the changeset viewer.