Skip to content

Commit

Permalink
Set Default state to media library for library button in image block (#…
Browse files Browse the repository at this point in the history
…41678)

* Set Default state to media library for library button in image block

* Updated changelog of media-upload component
  • Loading branch information
akasunil authored Jun 16, 2022
1 parent ec1cfe9 commit 7b47756
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ export function MediaPlaceholder( {
multiple={ multiple }
onSelect={ onSelect }
allowedTypes={ allowedTypes }
mode={ 'browse' }
value={
Array.isArray( value )
? value.map( ( { id } ) => id )
Expand Down
8 changes: 8 additions & 0 deletions packages/block-editor/src/components/media-upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ If allowedTypes is unset all mime types should be allowed.
- Required: No
- Platform: Web | Mobile

### mode

Value of Frame content default mode like 'browse', 'upload' etc.

- Type: `String`
- Required: No
- Default: false
- Platform: Web
### multiple

Whether to allow multiple selections or not.
Expand Down
5 changes: 5 additions & 0 deletions packages/media-utils/src/components/media-upload/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,11 @@ class MediaUpload extends Component {
onOpen() {
this.updateCollection();

//Handle active tab in media model on model open.
if ( this.props.mode ) {
this.frame.content.mode( this.props.mode );
}

// Handle both this.props.value being either (number[]) multiple ids
// (for galleries) or a (number) singular id (e.g. image block).
const hasMedia = Array.isArray( this.props.value )
Expand Down

0 comments on commit 7b47756

Please sign in to comment.