Skip to content
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

Add an error state to the image block to allow upload errors to display #10224

Merged
merged 8 commits into from
Dec 10, 2018
6 changes: 5 additions & 1 deletion packages/block-library/src/image/edit.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ class ImageEdit extends Component {
}

componentDidMount() {
const { attributes, setAttributes } = this.props;
const { attributes, setAttributes, noticeOperations } = this.props;
const { id, url = '' } = attributes;

if ( isTemporaryImage( id, url ) ) {
Expand All @@ -134,6 +134,10 @@ class ImageEdit extends Component {
setAttributes( pickRelevantMediaFiles( image ) );
},
allowedTypes: ALLOWED_MEDIA_TYPES,
onError: ( message ) => {
noticeOperations.createErrorNotice( message );
this.setState( { isEditing: true } );
},
} );
}
}
Expand Down