You are here

function theme_download_file_imagecache_accessiblelink_direct_download in DownloadFile 6

Theme function for the 'imagecache_accessiblelink_direct_download' multiple file formatter.

Parameters

$file: File to format.

$formatter: ImageCache formatter.

Return value

A string containing the HTML ouput.

1 theme call to theme_download_file_imagecache_accessiblelink_direct_download()
theme_download_file_formatter_imagecache_accessiblelink_direct_download in ./download_file.formatter.inc
Theming function for displaying the link accessible with a thumbnail ImageCache to direct download the image.

File

./download_file.formatter.inc, line 320
Download file formatter hooks and callbacks.

Code

function theme_download_file_imagecache_accessiblelink_direct_download($file, $formatter) {

  // Views may call this function with a NULL value, return an empty string.
  if (empty($file['fid'])) {
    return '';
  }

  // Extract the preset name from the formatter name.
  $presetname = substr($formatter, 0, strrpos($formatter, '_accessiblelink'));
  $style = 'accessiblelink';
  if ($preset = imagecache_preset_by_name($presetname)) {
    $url = download_file_path($file['fid']);
    $accessibility = theme('download_file_detail_accessible', $file);
    $options['html'] = TRUE;

    // Use the description as the link text if available.
    if (empty($file['data']['description'])) {
      $link_text = $file['filename'];
    }
    else {
      $link_text = $file['data']['description'];
      $options['attributes']['title'] = $file['filename'];
    }
    $file['data']['alt'] = isset($file['data']['alt']) ? $file['data']['alt'] : '';
    $file['data']['title'] = isset($file['data']['title']) ? $file['data']['title'] : NULL;
    $imagetag = theme('imagecache', $presetname, $file['filepath'], $file['data']['alt'], $file['data']['title']);
    $options['attributes']['class'] = 'imagecache imagecache-' . $presetname . ' imagecache-' . $style . ' imagecache-' . $formatter;
    return '<li>' . l($imagetag . ' ' . $link_text . ' ' . $accessibility, $url, $options) . '</li>';
  }
  return '<li><!-- imagecache formatter preset(' . $presetname . ') not found! --></li>';
}