Artwork for a media item that can be requested at a specified size.
The following example shows how to attach artwork to a content value:
```swift
let content = MusicContent(
id: track.id,
songTitle: track.title,
artistName: track.artist,
albumName: track.album,
type: .audio,
duration: .finite(track.duration),
artwork: Artwork(id: track.artworkID) { size in
let data = await loadArtworkData(size: size)
return try ArtworkRepresentation(data: data)
}
)
```
Creates an artwork whose image data loads on demand at the requested size.
The provider returns artwork that matches the requested size when possible.
One dimension may differ if the artwork's aspect ratio differs from the requested size.
If the requested size exceeds the artwork's maximum available size, the provider returns
the artwork at its maximum size without enlarging the image.
- Parameters:
- id: A unique identifier for this artwork.
- artworkProvider: A handler the system calls to request an ``ArtworkRepresentation`` for a specified size.
get · iOS 27.0+
id
TypeScript
get id(): string
Swift declaration
let id: String
A unique identifier for this artwork, which the system uses to cache artwork across fetches.