function ds_custom_formatters_preview_elements_alter in Custom Formatters 7.2
Implements hook_custom_formatters_preview_elements_alter().
File
- includes/
ds.inc, line 230 - Display Suite module integration.
Code
function ds_custom_formatters_preview_elements_alter(&$elements, $values) {
$ds_fields = ds_get_fields($elements['obj_type']);
if (in_array($values['preview']['field'], array_keys($ds_fields))) {
$elements['field'] = $ds_fields[$values['preview']['field']];
$elements['field']['field_name'] = $values['preview']['field'];
$elements['field']['entity'] = $elements['object'];
$elements['field']['entity_type'] = $elements['obj_type'];
$elements['field']['bundle'] = $values['preview']['bundle'];
$elements['field']['view_mode'] = 'full';
$elements['field']['build'] = array();
$elements['instance'] = array();
$elements['langcode'] = language_default('language');
foreach (array_keys($elements['field']['properties']['formatters']) as $formatter) {
if (strpos($formatter, 'custom_formatters_') !== 0) {
$temp_field = $elements['field'];
$temp_field['formatter'] = $formatter;
$elements['items'][$formatter] = $elements['field']['#original_field']['function']($temp_field);
}
}
$elements['display'] = array();
}
}