- if (is_array($_SESSION['compose']['attachments'][$id]))
- {
- $apath = $_SESSION['compose']['attachments'][$id]['path'];
- header('Content-Type: ' . $_SESSION['compose']['attachments'][$id]['mimetype']);
- header('Content-Length: ' . filesize($apath));
- readfile($apath);
- }
+ if ($attachment = $COMPOSE['attachments'][$id])
+ $attachment = $RCMAIL->plugins->exec_hook('attachment_display', $attachment);
+
+ if ($attachment['status']) {
+ if (empty($attachment['size']))
+ $attachment['size'] = $attachment['data'] ? strlen($attachment['data']) : @filesize($attachment['path']);
+
+ header('Content-Type: ' . $attachment['mimetype']);
+ header('Content-Length: ' . $attachment['size']);
+
+ if ($attachment['data'])
+ echo $attachment['data'];
+ else if ($attachment['path'])
+ readfile($attachment['path']);