public function getReferencingMedia($fid) {
    // Get media fields that reference files.
    $fields = $this->getReferencingFields('media', 'file');

    // Process field names, stripping off 'media.' and appending 'target_id'.
    $conditions = array_map(
      function ($field) {
        return ltrim($field, 'media.') . '.target_id';
      },
      $fields
    );

    // Query for media that reference this file.
    $query = $this->entityQuery->get('media', 'OR');
    foreach ($conditions as $condition) {
      $query->condition($condition, $fid);
    }

    return $this->entityTypeManager->getStorage('media')->loadMultiple($query->execute());
  }