-
Notifications
You must be signed in to change notification settings - Fork 4.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Helpful error on upload of image type not supported by server #68644
base: trunk
Are you sure you want to change the base?
Helpful error on upload of image type not supported by server #68644
Conversation
The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
$settings['typesNotSupportedByServer'] = array(); | ||
|
||
// Check if WebP images can be edited. | ||
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/webp' ) ) ) { | ||
$settings['typesNotSupportedByServer']['image/webp'] = true; | ||
} | ||
|
||
// Check if AVIF images can be edited. | ||
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/avif' ) ) ) { | ||
$settings['typesNotSupportedByServer']['image/avif'] = true; | ||
} | ||
|
||
// Check if HEIC images can be edited. | ||
if ( ! wp_image_editor_supports( array( 'mime_type' => 'image/heic' ) ) ) { | ||
$settings['typesNotSupportedByServer']['image/heic'] = true; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The release-specific code needs to go into the compat/wordpress-6.8
(next major version) folder. This will probably be a part of the get_default_block_editor_settings
function during backport.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, ok thanks for clarifying. I will move
Do you think we should return this error on the REST API level? The Plus, it removes the need to introduce another config argument for media upload utils. |
Good idea, I can try that. |
What?
Reject upload of image types not supported by server - match the behavior when trying to upload the same file types in the media library.
This will fix this issue reported in Trac: https://core.trac.wordpress.org/ticket/61167
Why?
Currently users can upload AVIF, WebP or HEIC images even if their web server doesn't support - meaning WordPress will be unable to process the uploaded image into the sub-sized images used for display on the front end. This matches what we do in the media library - we help users by suggesting they convert their images before uploading them
While the upload might look like it is working currently, since the sub-sized images are not created, the front experience is sub-par and the user might never realize this.
How?
Testing Instructions
Screenshots or screencast
Media library error:
Post editor error:
Missing srcset