I'm attempting to load the file attached to a media entity used in a field attached to a paragraph in order to create a url to the file.
$vid = $paragraph->get($field_name)?->entity?->toArray()['vid']['value']; $media['desktop_mp4'] = File::load($vid)?->createFileUrl();
$paragraph->get($field_name)?->entity does give me a proper Media object, which does have properties like 'vid' and 'mid' but I'm not sure what to use when loading the file attached to it.
In an example case I know that the ID is supposed to be 18 but sometimes that comes from the vid and sometimes that comes from the mid. Even when using the same media in the same field type there doesn't seem to be any consistency as to where the proper fid can be found in the array returned by $paragraph->get($field_name)?->entity?->toArray();
What should I be using to the fid from a media entity?