Skip to content

Commit

Permalink
SelectImage onMedia property
Browse files Browse the repository at this point in the history
  • Loading branch information
junaidbhura committed Dec 2, 2018
1 parent fc57d04 commit d16955f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion assets/dist/blocks.js

Large diffs are not rendered by default.

8 changes: 7 additions & 1 deletion assets/src/components/select-image/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ class SelectImage extends React.Component {

this.state = {
image: {},
media: {},
};
}

Expand All @@ -33,6 +34,9 @@ class SelectImage extends React.Component {
if ( prevState.image !== this.state.image && this.props.onChange ) {
this.props.onChange( JSON.stringify( this.state.image ) );
}
if ( prevState.media !== this.state.media && this.props.onMedia ) {
this.props.onMedia( this.state.media );
}
}

render() {
Expand Down Expand Up @@ -60,6 +64,7 @@ class SelectImage extends React.Component {
if ( ! media ) {
this.setState( {
image: {},
media: {},
} );
return;
}
Expand All @@ -73,6 +78,7 @@ class SelectImage extends React.Component {
alt: media.alt,
size: size,
},
media,
} );
} }
type="image"
Expand All @@ -82,7 +88,7 @@ class SelectImage extends React.Component {
placeholder={ placeholder }
image={ image }
open={ open }
onRemove={ () => this.setState( { image: {} } ) }
onRemove={ () => this.setState( { image: {}, media: {} } ) }
/>
) }
/>
Expand Down
2 changes: 1 addition & 1 deletion gumponents.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Description: Advanced Gutenberg components for WordPress.
* Author: Junaid Bhura
* Author URI: https://junaidbhura.com
* Version: 0.0.3
* Version: 0.0.4
*
* @package JB\Gumponents
*/
Expand Down

0 comments on commit d16955f

Please sign in to comment.