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

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

Parameters

$instance: The field instance being displayed.

$view_mode: The display mode.

$entity: The entity being displayed.

Return value

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

Related topics

File

modules/field/field.module, line 936
Attach custom data fields to Backdrop entities.

Code

function field_get_display($instance, $view_mode, $entity) {
  // Check whether the display 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,
  );
  backdrop_alter(array('field_display', 'field_display_' . $instance['entity_type']), $display, $context);

  return $display;
}