Contents

srcset

Specifies multiple URLs for an image.

Overview

Use the srcset attribute to specify different URLs for an image depending on the situation. The URL can point to an image on a server or to the resource scheme in your app. For a list of resource images provide by Apple, see the Resource Icons section of TVML. Here’s an example that displays a different chevron image depending whether the current language is a left-to-right or right-to-left language.

<img srcset="resource://chevron-right.png (layout-direction: ltr), resource://chevron-left.png (layout-direction: rtl)" />

srcset is also used to specify images for 4K devices. Non-4K images are indicated with a 1x, while 4K images are indicated with a 2x. Here’s an example showing how to specify different images for 4K and non-4K devies.

<img srcset="imageURL1 1x, imageURL2 2x" />

Values for srcset

String

The URL pointing to the location of the image file.

Elements that Use srcset

See Also

Image Retrieval