mirror of
https://github.com/WordPress/WordPress.git
synced 2025-03-25 09:28:42 +00:00
Media: Show an error message when a .heic
file is uploaded that this type of files cannot be displayed in a web browser and suggesting to convert to JPEG. The message is shown by using filters, plugins that want to handle uploading of .heic
files can remove it.
Props mattheweppelsheimer, mikeschroder, jeffr0, andraganescu, desrosj, azaozz. Fixes #42775. Built from https://develop.svn.wordpress.org/trunk@48288 git-svn-id: http://core.svn.wordpress.org/trunk@48057 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
054610e276
commit
86317e3e85
@ -15,6 +15,7 @@ add_action( 'activity_box_end', 'wp_dashboard_quota' );
|
||||
|
||||
// Media hooks.
|
||||
add_action( 'attachment_submitbox_misc_actions', 'attachment_submitbox_metadata' );
|
||||
add_filter( 'plupload_init', 'wp_show_heic_upload_error' );
|
||||
|
||||
add_action( 'media_upload_image', 'wp_media_upload_handler' );
|
||||
add_action( 'media_upload_audio', 'wp_media_upload_handler' );
|
||||
|
@ -534,6 +534,7 @@ add_filter( 'the_content', 'do_shortcode', 11 ); // AFTER wpautop().
|
||||
add_action( 'wp_playlist_scripts', 'wp_playlist_scripts' );
|
||||
add_action( 'customize_controls_enqueue_scripts', 'wp_plupload_default_settings' );
|
||||
add_action( 'plugins_loaded', '_wp_add_additional_image_sizes', 0 );
|
||||
add_filter( 'plupload_default_settings', 'wp_show_heic_upload_error' );
|
||||
|
||||
// Nav menu.
|
||||
add_filter( 'nav_menu_item_id', '_nav_menu_item_id_use_once', 10, 2 );
|
||||
|
@ -3046,6 +3046,7 @@ function wp_get_mime_types() {
|
||||
'bmp' => 'image/bmp',
|
||||
'tiff|tif' => 'image/tiff',
|
||||
'ico' => 'image/x-icon',
|
||||
'heic' => 'image/heic',
|
||||
// Video formats.
|
||||
'asf|asx' => 'video/x-ms-asf',
|
||||
'wmv' => 'video/x-ms-wmv',
|
||||
|
@ -568,6 +568,11 @@ jQuery( document ).ready( function( $ ) {
|
||||
uploadStart();
|
||||
|
||||
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 )
|
||||
}
|
||||
|
||||
fileQueued( file );
|
||||
});
|
||||
|
||||
|
2
wp-includes/js/plupload/handlers.min.js
vendored
2
wp-includes/js/plupload/handlers.min.js
vendored
File diff suppressed because one or more lines are too long
@ -351,6 +351,15 @@ window.wp = window.wp || {};
|
||||
return;
|
||||
}
|
||||
|
||||
if ( file.type === 'image/heic' && up.settings.heic_upload_error ) {
|
||||
// Show error but do not block uploading.
|
||||
Uploader.errors.unshift({
|
||||
message: pluploadL10n.unsupported_image,
|
||||
data: {},
|
||||
file: file
|
||||
});
|
||||
}
|
||||
|
||||
// Generate attributes for a new `Attachment` model.
|
||||
attributes = _.extend({
|
||||
file: file,
|
||||
|
2
wp-includes/js/plupload/wp-plupload.min.js
vendored
2
wp-includes/js/plupload/wp-plupload.min.js
vendored
File diff suppressed because one or more lines are too long
@ -3599,8 +3599,10 @@ function wp_plupload_default_settings() {
|
||||
*
|
||||
* @param array $params Default Plupload parameters array.
|
||||
*/
|
||||
$params = apply_filters( 'plupload_default_params', $params );
|
||||
$params['_wpnonce'] = wp_create_nonce( 'media-form' );
|
||||
$params = apply_filters( 'plupload_default_params', $params );
|
||||
|
||||
$params['_wpnonce'] = wp_create_nonce( 'media-form' );
|
||||
|
||||
$defaults['multipart_params'] = $params;
|
||||
|
||||
$settings = array(
|
||||
@ -4686,3 +4688,16 @@ function _wp_add_additional_image_sizes() {
|
||||
// 2x large size.
|
||||
add_image_size( '2048x2048', 2048, 2048 );
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to enable showig of the user error when uploading .heic images.
|
||||
*
|
||||
* @since 5.5.0
|
||||
*
|
||||
* @param array[] $plupload_settings The settings for Plupload.js.
|
||||
* @return array[] Modified settings for Plupload.js.
|
||||
*/
|
||||
function wp_show_heic_upload_error( $plupload_settings ) {
|
||||
$plupload_settings['heic_upload_error'] = true;
|
||||
return $plupload_settings;
|
||||
}
|
||||
|
@ -846,6 +846,7 @@ function wp_default_scripts( $scripts ) {
|
||||
'deleted' => __( 'moved to the Trash.' ),
|
||||
/* 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.' ),
|
||||
);
|
||||
|
||||
$scripts->add( 'moxiejs', "/wp-includes/js/plupload/moxie$suffix.js", array(), '1.3.5' );
|
||||
|
@ -13,7 +13,7 @@
|
||||
*
|
||||
* @global string $wp_version
|
||||
*/
|
||||
$wp_version = '5.5-alpha-48287';
|
||||
$wp_version = '5.5-alpha-48288';
|
||||
|
||||
/**
|
||||
* Holds the WordPress DB revision, increments when changes are made to the WordPress DB schema.
|
||||
|
Loading…
x
Reference in New Issue
Block a user