Same name and namespace in other branches
  1. 4.7.x modules/upload.module \theme_upload_attachments()
  2. 5.x modules/upload/upload.module \theme_upload_attachments()

Displays file attachments in table

Related topics

File

modules/upload/upload.module, line 351
File-handling and attaching files to nodes.

Code

function theme_upload_attachments($files) {
  $header = array(
    t('Attachment'),
    t('Size'),
  );
  $rows = array();
  foreach ($files as $file) {
    $file = (object) $file;
    if ($file->list && empty($file->remove)) {
      $href = file_create_url($file->filepath);
      $text = $file->description ? $file->description : $file->filename;
      $rows[] = array(
        l($text, $href),
        format_size($file->filesize),
      );
    }
  }
  if (count($rows)) {
    return theme('table', $header, $rows, array(
      'id' => 'attachments',
    ));
  }
}