You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`<Img>` component will render the image in the most optimized way.
89
+
90
+
`src` property can be either a filejet ID or HTTPs URL to external file.
91
+
92
+
```tsx
93
+
import { Img } from'@filejet/sdk/react';
94
+
95
+
<Img
96
+
src="KRhBC0tycdeENyP1PQkgBA"
97
+
thumbhash="HBkSHYSIeHiPiHh8eJd4eTN0EEQG"
98
+
height={168}
99
+
fit="cover"
100
+
alt="Photo"
101
+
/>;
102
+
```
103
+
104
+
**Recommended usage:**
105
+
106
+
It is recommended to alway use `thumbhash` in a combination with `height` to ensure dimensions are known before the image is loaded to prevent layout shift.
107
+
108
+
Thumbhash encodes both the blurred placeholder and its ratio, so client can avoid layout shifts even when the ratio is not known as it can be calculated from the thumbhash.
109
+
110
+
**Rendering process:**
111
+
Image starts with the single-color placeholder calculated from the average color of thumbhash. Then, when the image is in the viewport, the original image is fetched (scaled based on DPI). If the image is in browser's cache, it is rendered immediately. If not, the blurred placeholder is rendered until the image is loaded.
112
+
113
+
**Rendering priority:**
114
+
`priority` prop can be used to prioritize the image fetching, decoding and blurred placeholder rendering. Recommended value is `auto` (default). Using `low` will lead into longer time between the single-color placeholder and the real image.
0 commit comments