Drupal 7 Open File attachment Links in New Window

Published by burgerboydaddy on Wed, 11/07/2012 - 13:21


For requests like: Open attachment in new window code bellow should be placed inside template.php file:
Also return statement is wrapped with span/class that allows extra theming options.

function THEMENAME_file_link($variables) {
  $file = $variables['file'];
  $icon_directory = $variables['icon_directory'];

  $url = file_create_url($file->uri);
  $icon = theme('file_icon', array('file' => $file, 'icon_directory' => $icon_directory));

  // Set options as per anchor format described at