ant-design/components/image/index.en-US.md

46 lines
1.6 KiB
Markdown
Raw Normal View History

---
category: Components
type: Data Display
title: Image
cols: 2
cover: https://gw.alipayobjects.com/zos/antfincdn/D1dXz9PZqa/image.svg
---
Previewable image.
## When To Use
- When you need to display pictures.
- Display when loading a large image or fault tolerant handling when loading fail.
## API
| Property | Description | Type | Default | Version |
| --- | --- | --- | --- | --- |
| alt | Image description | string | - | 4.6.0 |
| fallback | Load failure fault-tolerant src | string | - | 4.6.0 |
| height | Image height | string \| number | - | 4.6.0 |
| placeholder | Load placeholder, use default placeholder when set `true` | ReactNode | - | 4.6.0 |
2020-09-28 14:15:23 +08:00
| preview | preview config, disabled when `false` | boolean \| [previewType](#previewType) | true | 4.6.0 [previewType](#previewType):4.7.0 |
| src | Image path | string | - | 4.6.0 |
| width | Image width | string \| number | - | 4.6.0 |
2021-02-02 13:35:37 +08:00
| onError | Load failed callback | (event: Event) => void | - | 4.12.0 |
| rootClassName | add custom className for image root DOM and preview mode root DOM | string | - | 4.20.0 |
2020-09-28 14:15:23 +08:00
### previewType
```js
2020-09-28 14:15:23 +08:00
{
visible?: boolean;
onVisibleChange?: (visible, prevVisible) => void;
2022-04-18 11:16:23 +08:00
getContainer?: string | HTMLElement | (() => HTMLElement); // v4.8.0
src?: string; // v4.10.0
mask?: ReactNode; // v4.9.0
maskClassName?: string; // v4.11.0
current?: number; // v4.12.0 Only support PreviewGroup
countRender?: (current: number, total: number) => string // v4.20.0 Only support PreviewGroup
2020-09-28 14:15:23 +08:00
}
```
Other attributes [<img>](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img#Attributes)