How to get all field names of field type


To obtain a list of all field names for fields of a specific type, such as image, you can use the entity_field.manager service:

$field_map = \Drupal::service('entity_field.manager')->getFieldMapByFieldType('image');

The $field_map array will contain a list of fields organized by entity type.


In summary, the entity_field.manager service in Drupal can be utilized to fetch field names based on their field type, offering a systematic way to categorize and manage fields.

About the Author

Goran Nikolovski is an experienced web and AI developer skilled in Drupal, React, and React Native. He founded this website and enjoys sharing his knowledge.