ImageWidget
This is a React component

Source
import { ImageWidget } from "@prestojs/ui-antd";
ImageWidget(props)

See FileWidget for props available

ParameterTypeDescription
*props

The props from Upload. Note that data, method, headers and withCredentials are ignored as this component doesn't upload immediately.

*props.childrenReact.ReactNode

Contents to render (eg. upload button etc). If not provided renders default Icon or Button depending on listType

*props.inputUploadWidgetInputType
*props.limitnumber|null

Number of files to allow. null means unlimited.

If limit is 1 then after uploading a file the UI will change from an Add icon to an Edit icon and uploading a new file will replace the original.

If limit is > 1 then once the limit has been reached the UI will disallow adding new files. To add a new file an existing one must be removed.

If multiple is true then the value passed to onChange will be an array, otherwise it will be a File object or null. It is valid to set limit to 1 and multiple to true.

Defaults to 1.

*props.multipleboolean

Whether multiple values are accepted. In most cases you can set limit to null or a value greater than 1 instead of explicitly setting this. This can be set to true when limit is 1 in order to enforce the value being an array (eg. this could be useful if limit increases based on something else).

If true input.value must be an array when set and onChange will be passed an array of File objects, otherwise it will be passed a single value or null.

If multiple is true and limit is 1 then the only difference to multiple={false} is that the value will be an array.

Defaults to false if limit is 1 otherwise true.