function field_get_display

7.x field.module field_get_display($instance, $view_mode, $entity)

Returns the display settings to use for an instance in a given view mode.

Parameters

$instance: The field instance being displayed.

$view_mode: The view mode.

$entity: The entity being displayed.

Return value

The display settings to be used when displaying the field values.

Related topics

2 calls to field_get_display()
field_default_prepare_view in drupal-7.x/modules/field/field.default.inc
Invokes hook_field_formatter_prepare_view() on the relevant formatters.
field_default_view in drupal-7.x/modules/field/field.default.inc
Builds a renderable array for one field on one entity instance.

File

drupal-7.x/modules/field/field.module, line 651
Attach custom data fields to Drupal entities.

Code

function field_get_display($instance, $view_mode, $entity) {
  // Check whether the view mode uses custom display settings or the 'default'
  // mode.
  $view_mode_settings = field_view_mode_settings($instance['entity_type'], $instance['bundle']);
  $actual_mode = (!empty($view_mode_settings[$view_mode]['custom_settings']) ? $view_mode : 'default');
  $display = $instance['display'][$actual_mode];

  // Let modules alter the display settings.
  $context = array(
    'entity_type' => $instance['entity_type'],
    'field' => field_info_field($instance['field_name']),
    'instance' => $instance,
    'entity' => $entity,
    'view_mode' => $view_mode,
  );
  drupal_alter(array('field_display', 'field_display_' . $instance['entity_type']), $display, $context);

  return $display;
}