-
Notifications
You must be signed in to change notification settings - Fork 8
ImageControl
Junaid Bhura edited this page Feb 2, 2019
·
4 revisions
import { ImageControl } = gumponents.components;
...
attributes: {
image: {
type: 'object',
default: null,
},
},
...
<ImageControl
label="Choose image"
selectLabel="Choose image"
removeLabel="Remove this image"
size="thumbnail"
value={ image }
onChange={ ( image, media ) => setAttributes( { image } ) }
/>
The label for the control.
- Type:
String
- Required: No
The help text for the control.
- Type:
String
- Required: No
The label for the select button.
- Type:
String
- Required: No
The label for the remove button.
- Type:
String
- Required: No
The thumbnail size name of the image.
- Type:
String
- Required: No
The value can be either the attachment ID or the original object returned as a value by this control. If only the attachment ID is passed, it performs an API call to get the image's details. If the whole object is passed, it saves the API call, making it more performant.
- Type:
Int
|Object
- Required: Yes
A function that receives the values of the control. This function has two parameters:
- An image object which can be saved as is in the attribute, and can be used in conjunction with the
<Img />
component to build animg
tag. - The entire media object, which can be used for other miscellaneous reasons.
- Type:
Function
- Required: Yes