---
title: QLPreviewReplyAttachment
framework: QuickLook UI
role: symbol
role_heading: Class
platforms: [macOS 12.0+]
path: quicklookui/qlpreviewreplyattachment
---

# QLPreviewReplyAttachment

An attachment for a Quick Look preview reply that provides additional content for the system to display a preview.

## Declaration

```swift
class QLPreviewReplyAttachment
```

## Overview

Overview When providing a data-based Quick Look preview with HTML, use QLPreviewReplyAttachment to include images, CSS, and other linked content in the HTML of the preview. Reference content in your HTML using the CID notation for the reference. For example, if your HTML preview response includes an image, create a QLPreviewReplyAttachment with the image, add it to the reply’s attachments with an associated string, and reference the image with the associated string, prefixed by cid:. The following example illustrates returning HTML as a preview reply with an image as an attachment: let reply = QLPreviewReply(dataOfContentType: .html,                            contentSize: CGSize(width: 750, height: 500)) { htmlReply in     let content = """                   <html>                   <head></head>                   <body>                   <h1>Preview</h1>                   <img src="cid:exampleImage" width="400">                   </body>                   </html>                   """     guard let contentData = content.data(using: .utf8) else {         throw PreviewError.previewSetupFailure("Unable to encode preview content")     }     guard let imageFileURL = Bundle.main.url(forResource: "yourImage",                                              withExtension: "jpg") else {         throw PreviewError.previewSetupFailure("unable to load image")     }     let imageData = try Data(contentsOf: imageFileURL)          htmlReply.attachments["exampleImage"] = QLPreviewReplyAttachment(data: imageData,                                                                      contentType: .jpeg)     return contentData } reply.title = "HTML Preview Example"

## Topics

### Creating a preview reply attachment

- [init(data:contentType:)](quicklookui/qlpreviewreplyattachment/init(data:contenttype:).md)

### Inspecting a preview reply attachment

- [contentType](quicklookui/qlpreviewreplyattachment/contenttype.md)
- [data](quicklookui/qlpreviewreplyattachment/data.md)

## Relationships

### Inherits From

- [NSObject](objectivec/nsobject-swift.class.md)

### Conforms To

- [CVarArg](swift/cvararg.md)
- [CustomDebugStringConvertible](swift/customdebugstringconvertible.md)
- [CustomStringConvertible](swift/customstringconvertible.md)
- [Equatable](swift/equatable.md)
- [Hashable](swift/hashable.md)
- [NSObjectProtocol](objectivec/nsobjectprotocol.md)

## See Also

### Data-based Preview Extensions

- [QLPreviewProvider](quicklookui/qlpreviewprovider.md)
- [QLFilePreviewRequest](quicklookui/qlfilepreviewrequest.md)
- [QLPreviewReply](quicklookui/qlpreviewreply.md)
