Make WordPress Core

Changeset 51227


Ignore:
Timestamp:
06/24/2021 07:10:32 PM (3 years ago)
Author:
azaozz
Message:

Media: Prevent uploading and show an error message when the server doesn't support editing of WebP images, take II. Add new, better error message for it.

Props antpb, joedolson, iandunn, azaozz.
Fixes #53475.

Location:
trunk/src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/js/_enqueues/vendor/plupload/handlers.js

    r51030 r51227  
    605605                if ( file.type === 'image/heic' && up.settings.heic_upload_error ) {
    606606                    // Show error but do not block uploading.
    607                     wpQueueError( pluploadL10n.unsupported_image )
     607                    wpQueueError( pluploadL10n.unsupported_image );
     608                } else if ( file.type === 'image/webp' && up.settings.webp_upload_error ) {
     609                    // Disallow uploading of WebP images if the server cannot edit them.
     610                    wpQueueError( pluploadL10n.noneditable_image );
     611                    up.removeFile( file );
     612                    return;
    608613                }
    609614
  • trunk/src/js/_enqueues/vendor/plupload/wp-plupload.js

    r50001 r51227  
    359359                        file:    file
    360360                    });
     361                } else if ( file.type === 'image/webp' && up.settings.webp_upload_error ) {
     362                    // Disallow uploading of WebP images if the server cannot edit them.
     363                    error( pluploadL10n.noneditable_image, {}, file, 'no-retry' );
     364                    up.removeFile( file );
     365                    return;
    361366                }
    362367
  • trunk/src/wp-admin/includes/media.php

    r50810 r51227  
    21992199    }
    22002200
     2201    // Check if WebP images can be edited.
     2202    if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
     2203        $plupload_init['webp_upload_error'] = true;
     2204    }
     2205
    22012206    /**
    22022207     * Filters the default Plupload settings.
  • trunk/src/wp-includes/media.php

    r51221 r51227  
    38593859    }
    38603860
     3861    // Check if WebP images can be edited.
     3862    if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
     3863        $defaults['webp_upload_error'] = true;
     3864    }
     3865
    38613866    /**
    38623867     * Filters the Plupload default settings.
  • trunk/src/wp-includes/script-loader.php

    r51223 r51227  
    876876        'error_uploading'           => __( '“%s” has failed to upload.' ),
    877877        'unsupported_image'         => __( 'This image cannot be displayed in a web browser. For best results convert it to JPEG before uploading.' ),
     878        'noneditable_image'         => __( 'This image cannot be processed by the web server. Convert it to JPEG or PNG before uploading.' ),
    878879        'file_url_copied'           => __( 'The file URL has been copied to your clipboard' ),
    879880    );
Note: See TracChangeset for help on using the changeset viewer.