function field_formatter_filter_preprocess_field in Field Formatter Filter 7
Same name and namespace in other branches
- 8 field_formatter_filter.module \field_formatter_filter_preprocess_field()
- 2.0.x field_formatter_filter.module \field_formatter_filter_preprocess_field()
Runs the text through the given filter.
We assume that the normal filter has already run here
- the items #markup is already prepared.
hook_preprocess field is right down close to the theme phase. There may be an earlier point to catch this. #markup was set when it hit text_field_formatter_view
Implements hook_preprocess_field().
File
- ./
field_formatter_filter.module, line 118 - Allows different text format filters to be applied as part of the field formatter settings for text fields.
Code
function field_formatter_filter_preprocess_field(&$variables, $hook) {
$entity_type = $variables['element']['#entity_type'];
$field_name = $variables['element']['#field_name'];
$bundle = $variables['element']['#bundle'];
$view_mode = $variables['element']['#view_mode'];
$formatter_info = field_formatter_settings_get_instance_display_settings($entity_type, $field_name, $bundle, $view_mode);
if (!empty($formatter_info['field_formatter_filter'])) {
$format_id = $formatter_info['field_formatter_filter'];
$language = $variables['element']['#language'];
foreach ($variables['items'] as $delta => $item) {
$variables['items'][$delta]['#markup'] = check_markup($item['#markup'], $format_id, $language);
}
}
}