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]. Reviewed by desrosj. Backports [60195] to the 6.8 branch. Props sirlouen, adamsilverstein, audrasjb, pbiron, sainathpoojary, dilipbheda, pratiklondhe. Fixes #63302. See #61167. Built from https://develop.svn.wordpress.org/branches/6.8@60196 git-svn-id: http://core.svn.wordpress.org/branches/6.8@59532 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
@@ -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.' ),
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '6.8.1-alpha-60194';
|
||||
$wp_version = '6.8.1-alpha-60196';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
||||
Reference in New Issue
Block a user