     }
 
 
-    fileprivate var currentSelectedAttachment: ImageAttachment?
+    fileprivate var currentSelectedAttachment: MediaAttachment?
 
     var loadSampleHTML = false
 

        switch attachment {
        case let attachment as HTMLAttachment:
            displayUnknownHtmlEditor(for: attachment)
        case let attachment as ImageAttachment:
            selected(textAttachment: attachment, atPosition: position)
        case let attachment as VideoAttachment:
            if let imageAttachment = currentSelectedAttachment {
                deselected(textAttachment: imageAttachment, atPosition: position)
            }
            selected(videoAttachment: attachment, atPosition: position)
        default:
            break
        }

        })
        alertController.addAction(removeAction)

        if let imageAttachment = attachment as? ImageAttachment {
            let detailsAction = UIAlertAction(title:NSLocalizedString("Media Details", comment: "User action to change media details."),
                                              style: .default,
                                              handler: { (action) in
                                                self.displayDetailsForAttachment(imageAttachment, position: position)
            })
            alertController.addAction(detailsAction)
        } else if let videoAttachment = attachment as? VideoAttachment, let videoURL = videoAttachment.srcURL {
            let detailsAction = UIAlertAction(title:NSLocalizedString("Play Video", comment: "User action to play video."),
                                              style: .default,
                                              handler: { (action) in
                                                self.displayVideoPlayer(for: videoURL)
            })
            alertController.addAction(detailsAction)
        }

        alertController.title = title
        alertController.message = message
