-
Notifications
You must be signed in to change notification settings - Fork 8
SelectImage
Junaid Bhura edited this page Mar 4, 2019
·
7 revisions
This component is used to select an image within the editor. It provides an easy to use interface to select and remove an image.
import { SelectImage } = gumponents.components;
...
attributes: {
image: {
type: 'object',
default: null,
},
},
...
<SelectImage
image={ image }
placeholder="Choose an image"
size="full"
onChange={ ( image, media ) => {
setAttributes( { image: null } ); // The block editor doesn't update objects correctly? 🤷♂️
setAttributes( { image } );
} }
showCaption={ true }
/>
The original saved image object attribute.
- Type:
Object
- Required: Yes
The thumbnail size name of the image.
- Type:
String
- Required: No
Placeholder text value.
- Type:
String
- Required: No
Show or hide a caption input below the image.
- Type:
Boolean
- Required: No
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