mirror of
git://develop.git.wordpress.org/
synced 2025-03-20 12:00:03 +01:00
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. git-svn-id: https://develop.svn.wordpress.org/trunk@51227 602fd350-edb4-49c9-b593-d223f7449a82
This commit is contained in:
parent
f5ae410c33
commit
22bd19e9dd
7
src/js/_enqueues/vendor/plupload/handlers.js
vendored
7
src/js/_enqueues/vendor/plupload/handlers.js
vendored
@ -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 );
|
||||
|
@ -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.
|
||||
|
@ -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.
|
||||
*
|
||||
|
@ -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' ),
|
||||
);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user