Skip navigation
Help

field_get_display

7 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()

File

drupal/modules/field/field.module, line 653
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;
}