The above example shows usage of the
<Image /> Component:
srcprop is required, and contains the path to the image you want to embed.
altprop holds a text description of the image, which isn't mandatory but is incredibly useful for accessibility — screen readers read this description out to their users so they know what the image means. Alt text is also displayed on the page if the image can't be loaded for some reason: for example, network errors, content blocking, or linkrot.
type prop is passed in as the Supported image format a sumarry is placed here below
This is passed in as the
type props as a string.
The HTML standard doesn't list what image formats to support, so each user agent supports different formats. Below is a list of the image formats that are most commonly used on the web.
The image file formats that are most commonly used on the web are listed below.
Indicates if the fetching of the image must be done using a CORS request. Image data from a CORS-enabled image returned from a CORS request can be reused in the
<canvas> element without being marked "tainted".
crossorigin prop is not specified, then a non-CORS request is sent (without the Origin request header), and the browser marks the image as tainted and restricts access to its image data, preventing its usage in
crossorigin prop is specified, then a CORS request is sent (with the Origin request header); but if the server does not opt into allowing cross-origin access to the image data by the origin site (by not sending any Access-Control-Allow-Origin response header, or by not including the site's origin in any Access-Control-Allow-Origin response header it does send), then the browser marks the image as tainted and restricts access to its image data, preventing its usage in
The CORS request is sent with any credentials included (that is, cookies, X.509 certificates, and the Authorization request header). If the server does not opt into sharing credentials with the origin site (by sending back the Access-Control-Allow-Credentials: true response header), then the browser marks the image as tainted and restricts access to its image data. If the attribute has an invalid value, browsers handle it as if the anonymous value was used. See CORS settings attributes for additional information.
Provides an image decoding hint to the browser. Allowed values:
Decode the image synchronously, for atomic presentation with other content.
Default: Decode the image asynchronously, to reduce delay in presenting other content.
No preference for the decoding mode. The browser decides what is best for the user.
The intrinsic height of the image, in pixels. Must be an integer without a unit.
Indicates how the browser should load the image:
Loads the image immediately, regardless of whether or not the image is currently within the visible viewport.
Defers loading the image until it reaches a calculated distance from the viewport, as defined by the browser. The intent is to avoid the network and storage bandwidth needed to handle the image until it's reasonably certain that it will be needed. This generally improves the performance of the content in most typical use cases.
This is a depreciated atrributte
Aligns the image with its surrounding context. Use the float and/or vertical-align CSS properties instead of this attribute. Allowed values:
Equivalent to vertical-align: top or vertical-align: text-top
Equivalent to vertical-align: -moz-middle-with-baseline
The default, equivalent to vertical-align: unset or vertical-align: initial
Equivalent to float: left
Equivalent to float: right
One or more strings separated by commas, indicating possible image sources for the user agent to use. Each string is composed of:
- A URL to an image
- Optionally, whitespace followed by one of:
- A width descriptor (a positive integer directly followed by w). The width descriptor is divided by the source size given in the sizes attribute to calculate the effective pixel density.
- A pixel density descriptor (a positive floating point number directly followed by x).
If no descriptor is specified, the source is assigned the default descriptor of 1x.
It is incorrect to mix width descriptors and pixel density descriptors in the same srcset attribute. Duplicate descriptors (for instance, two sources in the same srcset which are both described with 2x) are also invalid.
The user agent selects any of the available sources at its discretion. This provides them with significant leeway to tailor their selection based on things like user preferences or bandwidth conditions. See our Responsive images tutorial for an example.
The intrinsic width of the image in pixels. Must be an integer without a unit.