Skip to content

Commit

Permalink
Add an error state to the image block to allow upload errors to displ…
Browse files Browse the repository at this point in the history
…ay (#10224)
  • Loading branch information
brentswisher authored and talldan committed Dec 10, 2018
1 parent 8a5486d commit b6949b9
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/block-library/src/image/edit.js
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

0 comments on commit b6949b9

Please sign in to comment.