7.x field.api.php hook_field_formatter_info()

Expose Field API formatter types.

Formatters handle the display of field values. Formatter hooks are typically called by the Field Attach API field_attach_prepare_view() and field_attach_view() functions.

Return value

An array describing the formatter types implemented by the module. The keys are formatter type names. To avoid name clashes, formatter type names should be prefixed with the name of the module that exposes them. The values are arrays describing the formatter type, with the following key/value pairs:

  • label: The human-readable name of the formatter type.
  • description: A short description for the formatter type.
  • field types: An array of field types the formatter supports.
  • settings: An array whose keys are the names of the settings available for the formatter type, and whose values are the default values for those settings.

See also




Related topics

7 functions implement hook_field_formatter_info()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

field_test_field_formatter_info in modules/field/tests/field_test.field.inc
Implements hook_field_formatter_info().
file_field_formatter_info in modules/file/file.field.inc
Implements hook_field_formatter_info().
image_field_formatter_info in modules/image/image.field.inc
Implements hook_field_formatter_info().
list_field_formatter_info in modules/field/modules/list/list.module
Implements hook_field_formatter_info().
number_field_formatter_info in modules/field/modules/number/number.module
Implements hook_field_formatter_info().

... See full list


modules/field/field.api.php, line 1065
Hooks provided by the Field module.


function hook_field_formatter_info() {
  return array(
    'text_default' => array(
      'label' => t('Default'),
      'field types' => array(
    'text_plain' => array(
      'label' => t('Plain text'),
      'field types' => array(
    // The text_trimmed formatter displays the trimmed version of the
    // full element of the field. It is intended to be used with text
    // and text_long fields. It also works with text_with_summary
    // fields though the text_summary_or_trimmed formatter makes more
    // sense for that field type.
    'text_trimmed' => array(
      'label' => t('Trimmed'),
      'field types' => array(
    // The 'summary or trimmed' field formatter for text_with_summary
    // fields displays returns the summary element of the field or, if
    // the summary is empty, the trimmed version of the full element
    // of the field.
    'text_summary_or_trimmed' => array(
      'label' => t('Summary or trimmed'),
      'field types' => array(


chaiwei’s picture

I have been scratching my head all day trying to figure this out.

I am trying to create another formatter for file field. I have created MYMODULE_field_formatter_info() ,
MYMODULE_field_formatter_view() ,
and go to content type -> manage field -> change to my own formatter
but when I view the page nothing appear, I have even clear the cache for more than 100 times. It's still display an empty page.


It turns out it was because of I am using the same module name and theme name. Drupal find the theme_file_custom_display in my sites/all/themes folder.

Rename my module solved the problem.

greendemiurge’s picture

N.B. The key name is 'field types', not 'field_types' like you might expect if you are running on autopilot. There goes a half hour of my life.

Myko’s picture

list_boolean - Boolean
number_decimal - Decimal
file - File
number_float - loat
image - Image
number_integer - Integer
list_float - List (float)
list_integer - List (integer)
list_text - List (text)
text_long - Long text
text_with_summary - Long text and summary
taxonomy_term_reference - Term reference
text - Text

joshbrown81’s picture

user_reference - User Reference

Marc Loyat’s picture

field_collection - Field collection

ellioseven’s picture

entityreference = Entity Reference