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 youknowriad committed Jan 9, 2019
1 parent fab4335 commit 48ef727
Showing 1 changed file with 5 additions and 1 deletion.
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

0 comments on commit 48ef727

Please sign in to comment.