Im trying to use function theme_preprocess_field to get the file path of a file field.
I have tried different variations of below.
function mytheme_preprocess_field(&$variables) {
if ($variables['element']['#field_name'] == 'my_file_field') {
$uri = \Drupal\file\Entity\File::load($variables['items'][0]['content']['#item']->getValue())->getFileUri();
$variables['my_file_field_path'] = $uri;
}
}
In my instance it says value null, but it isn't.
How can I get the file path of my_file_field? Thanks