Created
August 3, 2012 05:58
-
-
Save mattcuro/3244939 to your computer and use it in GitHub Desktop.
Unimel file field formatter: large
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$formatter = new stdClass(); | |
$formatter->disabled = FALSE; /* Edit this to true to make a default formatter disabled initially */ | |
$formatter->api_version = 2; | |
$formatter->name = 'unimel_download_large'; | |
$formatter->label = 'unimel download large'; | |
$formatter->description = 'Styles a file field that users can download as per the Unimelb branding.'; | |
$formatter->mode = 'php'; | |
$formatter->field_types = 'file'; | |
$formatter->code = 'foreach ($variables[\'#items\'] as $item) { | |
$filepath = file_create_url($item[\'uri\']); | |
$filesize = format_size($item[\'filesize\']); | |
$filetype = explode(\'.\', $item[\'filename\']); | |
$output = l( | |
\'<strong>Download</strong>\' . $item[\'filename\'] . \'<em>(\' . $filesize . \')</em>\', | |
$filepath, | |
array( | |
\'attributes\' => array( | |
\'class\' => \'icon document large\', | |
\'rel\' => $filetype[1], | |
), | |
\'html\' => TRUE, | |
) | |
); | |
return $output; | |
}'; | |
$formatter->fapi = ''; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment