Alters the display settings of a field before it is displayed.
Modules can implement hook_field_display_ENTITY_TYPE_alter() to alter display settings for fields on a specific entity type, rather than implementing hook_field_display_alter().
This hook is called once per field per displayed entity. If the result of the hook involves reading from the database, it is highly recommended to statically cache the information.
array $display_properties: The display settings that will be used to display the field values, as found in the 'display' key of $instance definitions.
array $context: An associative array containing:
Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.
function hook_field_display_ENTITY_TYPE_alter(array &$display_properties, array $context) {
// Leave field labels out of the search index.
if ($context['view_mode'] == 'search_index') {
$display_properties['label'] = 'hidden';
}
}