---
title: OptimizeImage
---

import LibraryInfo from '@theme/LibraryInfo'
import { Feedback, PropsTable } from '../../src/components'
import { OptimizeImage } from '@telus-uds/components-web'
import { OptimizeImage as WebDocs } from 'docs/@telus-uds/components-web'
import AvailableOnWebOnly from '../../partials/_platform-considerations-web-only.mdx'
import NoStylisticVariants from '../../partials/_variants-none.mdx'

# OptimizeImage

<LibraryInfo packageType="Web Component" />

```jsx live
<OptimizeImage
  contentfulAssetUrl="/universal-design-system/img/pigs-allium-lo.png"
  alt="guinea pig"
/>
```

## Introduction

Used to optimize image files based on screen size.

[Follow the appropriate instructions](importing-components) to add this component in to your app.

## Guidance

- Must use a contentful asset url as the component adapts the url to convert the image file
- May customize quality and screen width sizes. Note: increasing quality and width may affect page performance
- `disableRetina` can be set so that an increased image size for retina screens is not displayed
- `sizeByHeight` prop allows you to switch the image dimension to height (default is width)
- Pass `'lazy'` via the `loading` prop to make the image
  [lazy-loading](https://developer.mozilla.org/en-US/docs/Web/Performance/Lazy_loading#images_and_iframes)

### Accessibility

Always provide an `alt` attribute for images with a short description of the image. You can use an empty string (`""`) if the image is purely decorative and conveys no information.

### Platform considerations

<AvailableOnWebOnly />

## Props

<PropsTable web={WebDocs} />

## Variants

<NoStylisticVariants />

## Feedback

<Feedback component="OptimizeImage" />
