Skip to content

Commit

Permalink
Edit the MediaUpload documentation about Upload Permissions
Browse files Browse the repository at this point in the history
Include some informations about how to make sure the current user has upload permissions (by wrapping the MediaUpload component into the MediaUploadCheck one)
  • Loading branch information
imath committed Nov 17, 2018
1 parent e933573 commit 423e9b3
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions packages/editor/src/components/media-upload/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,28 @@ You can check how this component is implemented for the edit post page using `wp

## Usage

To make sure the current user has Upload permissions, you need to wrap the MediaUpload component into the MediaUploadCheck one.

```jsx
import { Button } from '@wordpress/components';
import { MediaUpload } from '@wordpress/editor';
import { MediaUpload, MediaUploadCheck } from '@wordpress/editor';

const ALLOWED_MEDIA_TYPES = [ 'audio' ];

function MyMediaUploader() {
return (
<MediaUpload
onSelect={ ( media ) => console.log( 'selected ' + media.length ) }
allowedTypes={ ALLOWED_MEDIA_TYPES }
value={ mediaId }
render={ ( { open } ) => (
<Button onClick={ open }>
Open Media Library
</Button>
) }
/>
<MediaUploadCheck>
<MediaUpload
onSelect={ ( media ) => console.log( 'selected ' + media.length ) }
allowedTypes={ ALLOWED_MEDIA_TYPES }
value={ mediaId }
render={ ( { open } ) => (
<Button onClick={ open }>
Open Media Library
</Button>
) }
/>
</MediaUploadCheck>
);
}
```
Expand Down

0 comments on commit 423e9b3

Please sign in to comment.