Components
Get all entity reference fields that target media entities
To get a list of all entity reference fields that target media entities you can use the Entity type manager and the loadByProperties() method.
$fields = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties([
'type' => 'entity_reference',
'settings' => [
'target_type' => 'media',
],
]);
Get all dynamic entity reference fields
In the same way, you can get a list of dynamic entity reference fields.
$fields = \Drupal::entityTypeManager()->getStorage('field_storage_config')->loadByProperties([
'type' => 'dynamic_entity_reference',
]);
The $fields variable will contain an array of FieldStorageConfig instances for each field that satisfies the condition.
This won't return fields that are defined as BaseFieldDefinition in your code.