function media_field_formatter_view in D7 Media 7
Same name and namespace in other branches
- 7.4 includes/media.fields.inc \media_field_formatter_view()
- 7.2 includes/media.fields.inc \media_field_formatter_view()
- 7.3 includes/media.fields.inc \media_field_formatter_view()
Implement hook_field_formatter_view().
File
- includes/
media.fields.inc, line 180 - : Provides a "Multimedia asset" field to the fields API
Code
function media_field_formatter_view($entity_type, $entity, $field, $instance, $langcode, $items, $display) {
$element = array();
if ($display['type'] == 'media_large_icon') {
foreach ($items as $delta => $item) {
$element[$delta] = array(
'#theme' => 'media_formatter_large_icon',
'#file' => (object) $item,
);
}
}
// Legacy support for the extra formatter added to file fields. See
// media_field_formatter_info().
if ($display['type'] == 'media') {
$files = array();
foreach ($items as $delta => $item) {
if (!empty($item['file'])) {
$files[$item['fid']] = $item['file'];
}
}
if (!empty($files)) {
$element = file_view_multiple($files, $display['settings']['file_view_mode'], 0, $langcode);
}
}
return $element;
}