How to get all field names of field type

Components

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.

Image

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 a senior developer with over 10 years of experience turning ideas into scalable digital products—from web platforms and mobile apps to AI-powered tools. He is passionate about clean code, creative problem-solving, and shaping the future of digital development.

AI Assistant