diff --git a/packages/editor/src/components/media-placeholder/index.js b/packages/editor/src/components/media-placeholder/index.js index 48d906254c563c..4334aa3b5a2d2f 100644 --- a/packages/editor/src/components/media-placeholder/index.js +++ b/packages/editor/src/components/media-placeholder/index.js @@ -258,8 +258,13 @@ class MediaPlaceholder extends Component { } const applyWithSelect = withSelect( ( select ) => { + let hasUploadPermissions = false; + if ( undefined !== select( 'core' ) ) { + hasUploadPermissions = select( 'core' ).hasUploadPermissions(); + } + return { - hasUploadPermissions: select( 'core' ).hasUploadPermissions(), + hasUploadPermissions: hasUploadPermissions, }; } ); diff --git a/packages/editor/src/components/media-upload/check.js b/packages/editor/src/components/media-upload/check.js index df9bab268a1d52..13f9fac617f5a7 100644 --- a/packages/editor/src/components/media-upload/check.js +++ b/packages/editor/src/components/media-upload/check.js @@ -3,13 +3,17 @@ */ import { withSelect } from '@wordpress/data'; -export function MediaUploadCheck( { hasUploadPermissions, fallback, children } ) { - const optionalFallback = fallback || null; - return hasUploadPermissions ? children : optionalFallback; +export function MediaUploadCheck( { hasUploadPermissions, fallback = null, children } ) { + return hasUploadPermissions ? children : fallback; } export default withSelect( ( select ) => { + let hasUploadPermissions = false; + if ( undefined !== select( 'core' ) ) { + hasUploadPermissions = select( 'core' ).hasUploadPermissions(); + } + return { - hasUploadPermissions: select( 'core' ).hasUploadPermissions(), + hasUploadPermissions: hasUploadPermissions, }; } )( MediaUploadCheck ); diff --git a/packages/format-library/src/image/index.js b/packages/format-library/src/image/index.js index a1720a78bc10c9..c26bcca626a5dd 100644 --- a/packages/format-library/src/image/index.js +++ b/packages/format-library/src/image/index.js @@ -3,7 +3,7 @@ */ import { Path, SVG } from '@wordpress/components'; import { __ } from '@wordpress/i18n'; -import { Fragment, Component } from '@wordpress/element'; +import { Component } from '@wordpress/element'; import { insertObject } from '@wordpress/rich-text'; import { MediaUpload, RichTextInserterItem, MediaUploadCheck } from '@wordpress/editor'; @@ -47,34 +47,32 @@ export const image = { return ( - - } - title={ __( 'Inline Image' ) } - onClick={ this.openModal } - /> - { this.state.modal && { - this.closeModal(); - onChange( insertObject( value, { - type: name, - attributes: { - className: `wp-image-${ id }`, - style: `width: ${ Math.min( width, 150 ) }px;`, - url, - alt, - }, - } ) ); - } } - onClose={ this.closeModal } - render={ ( { open } ) => { - open(); - return null; - } } - /> } - + } + title={ __( 'Inline Image' ) } + onClick={ this.openModal } + /> + { this.state.modal && { + this.closeModal(); + onChange( insertObject( value, { + type: name, + attributes: { + className: `wp-image-${ id }`, + style: `width: ${ Math.min( width, 150 ) }px;`, + url, + alt, + }, + } ) ); + } } + onClose={ this.closeModal } + render={ ( { open } ) => { + open(); + return null; + } } + /> } ); }