From 423e9b35eb04d2e85d835bf509ef257cedba22ea Mon Sep 17 00:00:00 2001 From: imath Date: Sat, 17 Nov 2018 06:28:33 +0100 Subject: [PATCH] Edit the MediaUpload documentation about Upload Permissions Include some informations about how to make sure the current user has upload permissions (by wrapping the MediaUpload component into the MediaUploadCheck one) --- .../src/components/media-upload/README.md | 25 +++++++++++-------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/packages/editor/src/components/media-upload/README.md b/packages/editor/src/components/media-upload/README.md index ae670b227ea92..1dc11cb2a37ed 100644 --- a/packages/editor/src/components/media-upload/README.md +++ b/packages/editor/src/components/media-upload/README.md @@ -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 ( - console.log( 'selected ' + media.length ) } - allowedTypes={ ALLOWED_MEDIA_TYPES } - value={ mediaId } - render={ ( { open } ) => ( - - ) } - /> + + console.log( 'selected ' + media.length ) } + allowedTypes={ ALLOWED_MEDIA_TYPES } + value={ mediaId } + render={ ( { open } ) => ( + + ) } + /> + ); } ```