Load a media entity/object from a fid? I have the file ID (fid), and the rest of the file object.

I need to get fields from the parent media entity, but I can't find anything about loading a media entity from a file object.

Drupal 8.4.0

Update

I asked this question in relation to another: Media name as link to file

As far as I could find Kevin's comment is correct.
Using the service file.uses you get the file media object:

Example:

$file is a loaded file object.
$file = \Drupal::entityTypeManager()-&gt;getStorage('file')-&gt;load($fid)
$result = \Drupal::service('file.usage')-&gt;listUsage($file);


$result should now contain an array like so:

$result['file']['media']['4372'] = 2;


Where 4372 is the media id. and 2 the times the file is used.

From the docs of listUsage:

@return array
   *   A nested array with usage data. The first level is keyed by module name,
   *   the second by object type and the third by the object id. The value of
   *   the third level contains the usage count.