There was a solution posted here for version 4, but in 6.2 it has no effect.
http://drupal.org/node/116506#comment-197429
Does anyone know how to modify the upload attachment code to open a new window when a link is clicked there?

Comments

wadley0’s picture

This worked for me:
Add the following code into the template.php file of your theme. This is based on the code from bottdev in the link you provided, but updated for drupal 6. The key in the update is that passing attributes to the link function has been modified. See api for function l().

/**
 *  Override for attachments to be target="_blank"
 */
function phptemplate_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, array('attributes' => array('target' => '_blank'))), format_size($file->filesize));
    }
  }
  if (count($rows)) {
    return theme('table', $header, $rows, array('id' => 'attachments'));
  }
}

knalstaaf’s picture