-
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
Image: Display errors after failed upload #39178
Conversation
Size Change: +333 B (0%) Total Size: 1.15 MB
ℹ️ View Unchanged
|
Thanks for testing, @glendaviesnz. It's interesting that we get different behavior for emulated and actual errors. I reverted the |
@@ -171,6 +171,7 @@ export function ImageEdit( { | |||
function onUploadError( message ) { | |||
noticeOperations.removeAllNotices(); | |||
noticeOperations.createErrorNotice( message ); | |||
setTemporaryURL( undefined ); |
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.
I realized that we only need to reset the state. The onSelectImage
will remove attributes for us. It's called during the error but with an undefined media
argument.
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.
This is a weird one 🤔 - for me this change causes the php.ini upload limit error to be ignored, but only in the gallery:
img-error.mp4
Seems like there are a couple of gotchas
with how gallery versus individual images blocks are behaving with these errors, which would be good to work out why and resolve, or at least document. I will try and get a closer look at it later today.
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.
I had another look at it, and for some reason it seems like the standalone Image block goes through an extra render cycle which causes image to be removed and error to display, but this doesn't happen if the Image block is in a Gallery, but I can't work out why, as the Gallery essentially just delegates the upload process to the Image block. I will take another look at it tomorrow if you don't have any ideas.
We could just put the setAttributes back, but it would be nice to know why this is happening.
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.
Thanks for testing, @glendaviesnz. I will revert setAttributes
removal.
I would love to refactor the whole Image block at some point - the |
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.
Tested again and this now works for me in all the following instances:
- Single image with mocked error and genuine error from exceeding ini max file setting
- Gallery images with mocked error and genuine error from exceeding ini max file setting
Thanks for the reviews, @glendaviesnz 🙇 |
Description
Resolves #39116
PR ixes the issue when the upload error message wasn't displayed. Also re-uses
onUploadError
callback for error messages.Testing Instructions
Example
Screenshots
Before
CleanShot.2022-03-03.at.09.09.44.mp4
After
CleanShot.2022-03-03.at.09.15.09.mp4
Types of changes
Bugfix
Checklist:
*.native.js
files for terms that need renaming or removal).