You are here

function theme_file_entity_file_link in File Entity (fieldable files) 7

Same name and namespace in other branches
  1. 8.2 file_entity.theme.inc \theme_file_entity_file_link()
  2. 7.3 file_entity.theme.inc \theme_file_entity_file_link()
  3. 7.2 file_entity.theme.inc \theme_file_entity_file_link()

A copy of theme_file_file_link() that makes the link point to file/[fid].

Return value

type

See also

theme_file_file_link()

1 theme call to theme_file_entity_file_link()
file_entity_admin_files in ./file_entity.admin.inc
Administrative form for browsing files and performing operations on them.

File

./file_entity.module, line 733
Extends Drupal file entities to be fieldable and viewable.

Code

function theme_file_entity_file_link($variables) {
  $file = $variables['file'];
  $icon_directory = $variables['icon_directory'];
  $url = 'file/' . $file->fid;
  $icon = theme('file_icon', array(
    'file' => $file,
    'icon_directory' => $icon_directory,
  ));

  // Set options as per anchor format described at
  // http://microformats.org/wiki/file-format-examples
  $options = array(
    'attributes' => array(
      'type' => $file->filemime . '; length=' . $file->filesize,
    ),
  );

  // Use the description as the link text if available.
  if (empty($file->description)) {
    $link_text = $file->filename;
  }
  else {
    $link_text = $file->description;
    $options['attributes']['title'] = check_plain($file->filename);
  }
  return '<span class="file">' . $icon . ' ' . l($link_text, $url, $options) . '</span>';
}