summaryrefslogtreecommitdiffstatshomepage
path: root/src
diff options
context:
space:
mode:
authorAaron Jorbin <jorbin@git.wordpress.org>2025-04-28 15:37:27 +0000
committerAaron Jorbin <jorbin@git.wordpress.org>2025-04-28 15:37:27 +0000
commit3284fb08ff60e33930a1468fce439b02725e831e (patch)
tree84e8f7cae1e1205da08ea3286ec96808b81117db /src
parentd861e301c74cb6f1e5d645638488c186c3798fc9 (diff)
downloadwordpress-3284fb08ff60e33930a1468fce439b02725e831e.tar.gz
wordpress-3284fb08ff60e33930a1468fce439b02725e831e.zip
Media: Don't try to resize image formats which can't be resized
While having a mime type with an "image" prefix, SVG images are in fact "Scalable Vector Graphics" that can be scaled directly. Follow-up to [60084]. Props sirlouen, adamsilverstein, audrasjb, pbiron, sainathpoojary, dilipbheda, pratiklondhe. Fixes #63302. See #61167. git-svn-id: https://develop.svn.wordpress.org/trunk@60195 602fd350-edb4-49c9-b593-d223f7449a82
Diffstat (limited to 'src')
-rw-r--r--src/wp-includes/rest-api/endpoints/class-wp-rest-attachments-controller.php12
1 files changed, 10 insertions, 2 deletions
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 4c49a1f335..589e0e2cce 100644
--- 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
@@ -155,8 +155,16 @@ class WP_REST_Attachments_Controller extends WP_REST_Posts_Controller {
isset( $files['file']['type'] ) &&
str_starts_with( $files['file']['type'], 'image/' )
) {
- // Check if the image editor supports the type.
- if ( ! wp_image_editor_supports( array( 'mime_type' => $files['file']['type'] ) ) ) {
+ // List of non-resizable image formats.
+ $editor_non_resizable_formats = array(
+ 'image/svg+xml',
+ );
+
+ // Check if the image editor supports the type or ignore if it isn't a format resizable by an editor.
+ if (
+ ! in_array( $files['file']['type'], $editor_non_resizable_formats, true ) &&
+ ! wp_image_editor_supports( array( 'mime_type' => $files['file']['type'] ) )
+ ) {
return new WP_Error(
'rest_upload_image_type_not_supported',
__( 'The web server cannot generate responsive image sizes for this image. Convert it to JPEG or PNG before uploading.' ),