Skip to content

Commit

Permalink
Call onMediaUpdate instead of onSelectMedia
Browse files Browse the repository at this point in the history
  • Loading branch information
pinarol committed Oct 28, 2019
1 parent 7903ace commit ee525fa
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 10 deletions.
4 changes: 1 addition & 3 deletions packages/block-library/src/media-text/edit.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,11 @@ class MediaTextEdit extends Component {
setAttributes( {
mediaAlt: media.alt,
mediaId: media.id,
mediaType,
mediaUrl: src || media.url,
imageFill: undefined,
focalPoint: undefined,
} );
if ( mediaType ) { // We don't want to delete mediaType
setAttributes( { mediaType } );
}
}

onMediaUpdate( media ) {
Expand Down
10 changes: 3 additions & 7 deletions packages/block-library/src/media-text/media-container.native.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,13 @@ class MediaContainer extends Component {
}

componentDidMount() {
const { mediaId, mediaUrl, onSelectMedia } = this.props;
const { mediaId, mediaUrl, onMediaUpdate } = this.props;

if ( mediaId && mediaUrl && ! isURL( mediaUrl ) ) {
if ( mediaUrl.indexOf( 'file:' ) === 0 ) {
requestMediaImport( mediaUrl, ( id, url, type ) => {
requestMediaImport( mediaUrl, ( id, url ) => {
if ( url ) {
onSelectMedia( {
media_type: type,
id,
url,
} );
onMediaUpdate( { id, url } );
}
} );
}
Expand Down

0 comments on commit ee525fa

Please sign in to comment.