<!--
{
  "availability" : [
    "iOS: 26.4.0 -",
    "iPadOS: 26.4.0 -",
    "macCatalyst: 26.4.0 -",
    "macOS: 26.4.0 -",
    "tvOS: 26.4.0 -",
    "visionOS: 26.4.0 -",
    "watchOS: 26.4.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "LinkPresentation",
  "identifier" : "/documentation/LinkPresentation/LinkMetadata/media(_:as:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Link Presentation",
      "LinkPresentation"
    ],
    "preciseIdentifier" : "s:16LinkPresentation0A8MetadataV5media_2asxSgAC10AttachmentV_xmtYaK16CoreTransferable0H0RzlF"
  },
  "title" : "media(_:as:)"
}
-->

# media(_:as:)

Loads the media data of this metadata for an attachment as the specified Transferable type if possible.

```
nonisolated func media<Media>(_ attachment: LinkMetadata.Attachment, as type: Media.Type) async throws -> Media? where Media : Transferable
```

## Parameters

`attachment`

The kind of attachment to access, such as `.image`, `.icon`, and `.video`.

`type`

The `Transferable` type to try to load the media data into. This type must support the content type of the attachment.

## Return Value

A value of the `Transferable` type produced by the media data, or `nil` if there is no media data for the attachment as that type.

## Discussion

For example, PNG image data can be extracted as a specific type from the metadata if available:

```swift
let value = try await metadata.media(.image, as: SwiftUI.Image.self) // `value` is a `SwiftUI.Image?`
```

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)