<!--
{
  "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/containsMedia(_:exportableAs:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Link Presentation",
      "LinkPresentation"
    ],
    "preciseIdentifier" : "s:16LinkPresentation0A8MetadataV13containsMedia_12exportableAsSbAC10AttachmentV_xmt16CoreTransferable0J0RzlF"
  },
  "title" : "containsMedia(_:exportableAs:)"
}
-->

# containsMedia(_:exportableAs:)

Determines if a specific `Transferable` type can be loaded for an attachment in the metadata.

```
nonisolated func containsMedia(_ attachment: LinkMetadata.Attachment, exportableAs type: (some Transferable).Type) -> Bool
```

## Parameters

`attachment`

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

`type`

The `Transferable` type of the media data to test.

## Return Value

`true` if the metadata contains the specified attachment and the attachment’s content type is compatible with the media type.

## Discussion

Use this function to immediately determine if metadata has some specific kind of media that can be coerced into a given type:

```swift
if metadata.containsMedia(.image, exportableAs: SwiftUI.Image.self) {
    // Load the image, and while waiting, display some loading indicator.
} else {
    // The metadata contains no image, so omit any UI for it.
}
```

---

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)