Skip to content

Commit b7963e3

Browse files
docs: document that plugin-ideal-image changes imported image types (facebook#12130)
1 parent 7da2c45 commit b7963e3

1 file changed

Lines changed: 19 additions & 0 deletions

File tree

website/docs/api/plugins/plugin-ideal-image.mdx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,25 @@ import thumbnail from './path/to/img.png';
3636
<Image img={require('./path/to/img.png')} />
3737
```
3838

39+
:::note
40+
41+
When `plugin-ideal-image` is installed, importing a supported image file no longer returns a plain URL string. Instead, it returns an object with the shape: `{ preSrc: string, src: { src: string, width: number, height: number } }`.
42+
43+
If you need to use the image in a standard `<img>` tag, access it like this:
44+
45+
```jsx
46+
<img
47+
src={image.src.src}
48+
width={image.src.width}
49+
height={image.src.height}
50+
alt="description"
51+
/>
52+
```
53+
54+
To avoid dealing with this object shape directly, it is recommended to use the `<Image>` component provided by this plugin instead.
55+
56+
:::
57+
3958
:::warning
4059

4160
This plugin registers a [Webpack loader](https://webpack.js.org/loaders/) that changes the type of imported/require images:

0 commit comments

Comments
 (0)