Created
February 17, 2019 06:07
-
-
Save sharazghouri/6c9ba5dadbf6ba53e8ec744553e4d3f4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Button } from '@wordpress/components'; | |
import { MediaUpload, MediaUploadCheck } from '@wordpress/editor'; | |
const ALLOWED_MEDIA_TYPES = [ 'audio' ]; | |
function MyMediaUploader() { | |
return ( | |
// will check user have permission to upload media | |
<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> | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment