Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Default state to media library for library button in image block #41678

Merged
merged 3 commits into from
Jun 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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