---
title: "setMedia(_:for:)"
framework: linkpresentation
role: symbol
role_heading: Instance Method
path: "linkpresentation/linkmetadata/setmedia(_:for:)"
---

# setMedia(_:for:)

Sets the media data in the metadata for an attachment.

## Declaration

```swift
nonisolated mutating func setMedia(_ media: some Transferable, for attachment: LinkMetadata.Attachment)
```

## Parameters

- `media`: The value to use for the media that corresponds to the specified attachment.
- `attachment`: The kind of attachment to modify, such as .image, .icon, and .video.

## Discussion

Discussion For example, a custom image can be set on some metadata: metadata.setMedia(myImage, for: .image)
