function theme_media_gallery_download_link in Media Gallery 7
Same name and namespace in other branches
- 7.2 media_gallery.theme.inc \theme_media_gallery_download_link()
Returns HTML for a link to a file.
@todo Move to Media module?
Parameters
$variables: An associative array containing:
- file: A file object to which the link will be created.
- text: (optional) The link text. Defaults to t('Download original image').
- options: (optional) Extra options to pass to l().
See also
2 theme calls to theme_media_gallery_download_link()
- theme_media_gallery_media_item_detail in ./
media_gallery.theme.inc - Displays a media item (entity) as its own page, within gallery context.
- theme_media_gallery_media_item_lightbox in ./
media_gallery.theme.inc - Displays a media item (entity) within a lightbox.
File
- ./
media_gallery.theme.inc, line 510 - Media Gallery Theming
Code
function theme_media_gallery_download_link($variables) {
$file = $variables['file'];
$text = $variables['text'];
$options = $variables['options'];
// Link to "media/FID/download", so that Drupal can set the
// Content-Disposition header as needed to instruct the browser to download
// rather than display the file. Append the file name at the end to work
// around Internet Explorer's deficiencies in understanding HTTP headers.
$path = 'media/' . $file->fid . '/download/' . $file->filename;
if (!isset($text)) {
$text = t('Download original image');
}
// Set options as per anchor format described at
// http://microformats.org/wiki/file-format-examples
$options['attributes']['type'] = $file->filemime . '; length=' . $file->filesize;
$options['attributes']['class'] = array(
'gallery-download',
);
return l($text, $path, $options);
}