A component that implements a replacement flow for various media objects. It is used to allow various blocks that use media to have a toolbar button for replacing it. I offers several options, such as:
- replace from Media Library
- replace using an URL
- replace by uploading new media
This component should be used as a child of a <BlockControls>
component.
The URL of the media.
- Type:
string
- Required: Yes
The Id of the attachment post type for the current media.
- Type:
Int
- Required: No
A list of media types allowed to replace the current media.
- Type:
Array
- Required: Yes
Comma delimited list of MIME types accepted for upload.
- Type:
string
- Required: Yes
Callback called before to start to upload the files. It receives an array with the files to upload before to the final process.
Callback used when media is replaced from the Media Library or when a new media is uploaded. It is called with one argument media
which is an object with all the media details.
- Type:
func
- Required: Yes
Callback used when media is replaced with an URL. It is called with one argument newURL
which is a string
containing the new URL.
- Type:
func
- Required: No
Callback called when an upload error happens and receives an error message as an argument.
- Type:
func
- Required: No
A string
value will be used as the label of the replace button. It can also accept Phrasing content
elements(ex. span
).
- Type:
string|Element
- Required: No
- Default:
Replace
Creates a media replace notice.
- Type:
func
- Required: No
Removes a media replace notice.
- Type:
func
- Required: No
- Type:
Element
- Required: No
If passed, children are rendered inside the dropdown.
- Type:
Element | func
- Required: No
If passed, children are rendered inside the dropdown. If a function is provided for this prop, it will receive an object with the onClose
prop as an argument.
- Type:
func
- Required: No
If passed, it will be used to render the provided button instead of the default one. It should accept and pass through button
props to a button
element.