How to use the @wordpress/editor.mediaUpload function in @wordpress/editor

To help you get started, we’ve selected a few @wordpress/editor examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github front / gutenberg-js / src / js / gutenberg-overrides / @wordpress / block-library / build-module / gallery / edit.js View on Github external
addFiles (files) {
    const currentImages = this.props.attributes.images || [];
    const { noticeOperations, setAttributes } = this.props;
    mediaUpload({
      allowedTypes: ALLOWED_MEDIA_TYPES,
      filesList: files,
      onFileChange: images => {
        const imagesNormalized = images.map(image => pickRelevantMediaFiles(image));
        setAttributes({
          images: currentImages.concat(imagesNormalized),
        });
      },
      onError: noticeOperations.createErrorNotice,
    });
  }
github godaddy-wordpress / coblocks / src / components / block-gallery / gallery-uploader.js View on Github external
addFiles( files ) {
		const currentImages = this.props.attributes.images || [];
		const { noticeOperations, setAttributes } = this.props;
		mediaUpload( {
			allowedTypes: helper.ALLOWED_MEDIA_TYPES,
			filesList: files,
			onFileChange: ( images ) => {
				setAttributes( {
					images: currentImages.concat( images ),
				} );
			},
			onError: noticeOperations.createErrorNotice,
		} );
	}
github WordPress / gutenberg / packages / block-library / src / gallery / edit.js View on Github external
addFiles( files ) {
		const currentImages = this.props.attributes.images || [];
		const { noticeOperations, setAttributes } = this.props;
		mediaUpload( {
			allowedType: 'image',
			filesList: files,
			onFileChange: ( images ) => {
				setAttributes( {
					images: currentImages.concat( images ),
				} );
			},
			onError: noticeOperations.createErrorNotice,
		} );
	}
github godaddy-wordpress / coblocks / src / blocks / services / service / edit.js View on Github external
replaceImage( files ) {
		mediaUpload( {
			allowedTypes: [ 'image' ],
			filesList: files,
			onFileChange: ( [ media ] ) =>
				this.props.setAttributes( { imageUrl: media.url, imageAlt: media.alt } ),
		} );
	}
github godaddy-wordpress / coblocks / src / components / background / dropzone.js View on Github external
addFile( files ) {
		mediaUpload( {
			allowedTypes: ALLOWED_BG_MEDIA_TYPES,
			filesList: files,
			onFileChange: ( [ media ] ) => this.onSelectFile( media ),
		} );
	}
github godaddy-wordpress / coblocks / src / blocks / media-card / edit.js View on Github external
onDropMedia( files ) {
		mediaUpload( {
			allowedTypes: ALLOWED_MEDIA_TYPES,
			filesList: files,
			onFileChange: ( [ media ] ) => this.onSelectMedia( media ),
		} );
	}
github godaddy-wordpress / coblocks / src / blocks / author / edit.js View on Github external
addImage( files ) {
		mediaUpload( {
			allowedTypes: [ 'image' ],
			filesList: files,
			onFileChange: ( [ media ] ) => this.onSelectImage( media ),
		} );
	}