I'm looking to preprocess a field.

The field type I'm wanting to preprocess is an entity reference field.

I need to know what view mode has been selected on the display settings for this field (see screenshot below).

Field display settings

This information is not made available in the $variables variable passed into preprocess_field.

So how can I get this load this information? I have tried looking for some Drupal-specific functions that would return these settings but haven't found anything that works.

Many thanks.

1 Answer 1


You're looking for field_info_instance()

Returns an array of instance data for a specific field and bundle

Example usage:

$info = field_info_instance('node', 'field_foo', 'article');
$display_settings = $info['display'];

$display_settings will be an array of display settings keyed by the view modes that are customisable for that content type and bundle.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.