Skip to content

Image Control

Mauricio Gelves edited this page Feb 7, 2022 · 10 revisions

The Image Control is intended for use within the editor sidebar, for example a block sidebar or a plugin sidebar.

Example of the image control component in use

This control allows users to select an image, remove a selected image or change a selected image. A small preview of the image is also shown. It is styled appropriately for use in the sidebar, alongside other core controls such as wp.components.TextControl.

Example usage:

const { ImageControl } = window.hm.controls;

<ImageControl
	label={ 'Image' }
	help={ 'Some more description text' }
	value={ attributes.image.id }
	onChange={ image => setAttributes( image ) }
/>
Clone this wiki locally