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. Built from https://develop.svn.wordpress.org/trunk@51227 git-svn-id: http://core.svn.wordpress.org/trunk@50836 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
09fda454d0
commit
936a38255b
|
@ -2198,6 +2198,11 @@ function media_upload_form( $errors = null ) {
|
|||
$plupload_init['multi_selection'] = false;
|
||||
}
|
||||
|
||||
// Check if WebP images can be edited.
|
||||
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
|
||||
$plupload_init['webp_upload_error'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the default Plupload settings.
|
||||
*
|
||||
|
|
|
@ -604,7 +604,12 @@ jQuery( document ).ready( function( $ ) {
|
|||
plupload.each( files, function( file ) {
|
||||
if ( file.type === 'image/heic' && up.settings.heic_upload_error ) {
|
||||
// Show error but do not block uploading.
|
||||
wpQueueError( pluploadL10n.unsupported_image )
|
||||
wpQueueError( pluploadL10n.unsupported_image );
|
||||
} else if ( file.type === 'image/webp' && up.settings.webp_upload_error ) {
|
||||
// Disallow uploading of WebP images if the server cannot edit them.
|
||||
wpQueueError( pluploadL10n.noneditable_image );
|
||||
up.removeFile( file );
|
||||
return;
|
||||
}
|
||||
|
||||
fileQueued( file );
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -358,6 +358,11 @@ window.wp = window.wp || {};
|
|||
data: {},
|
||||
file: file
|
||||
});
|
||||
} else if ( file.type === 'image/webp' && up.settings.webp_upload_error ) {
|
||||
// Disallow uploading of WebP images if the server cannot edit them.
|
||||
error( pluploadL10n.noneditable_image, {}, file, 'no-retry' );
|
||||
up.removeFile( file );
|
||||
return;
|
||||
}
|
||||
|
||||
// Generate attributes for a new `Attachment` model.
|
||||
|
|
File diff suppressed because one or more lines are too long
|
@ -3858,6 +3858,11 @@ function wp_plupload_default_settings() {
|
|||
$defaults['multi_selection'] = false;
|
||||
}
|
||||
|
||||
// Check if WebP images can be edited.
|
||||
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) {
|
||||
$defaults['webp_upload_error'] = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Filters the Plupload default settings.
|
||||
*
|
||||
|
|
|
@ -875,6 +875,7 @@ function wp_default_scripts( $scripts ) {
|
|||
/* translators: %s: File name. */
|
||||
'error_uploading' => __( '“%s” has failed to upload.' ),
|
||||
'unsupported_image' => __( 'This image cannot be displayed in a web browser. For best results convert it to JPEG before uploading.' ),
|
||||
'noneditable_image' => __( 'This image cannot be processed by the web server. Convert it to JPEG or PNG before uploading.' ),
|
||||
'file_url_copied' => __( 'The file URL has been copied to your clipboard' ),
|
||||
);
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.8-beta3-51226';
|
||||
$wp_version = '5.8-beta3-51227';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
|
Loading…
Reference in New Issue