How do I get an image path from field preprocess function
You can do this more simply

$uri = \Drupal\file\Entity\File::load($variables['items'][0]['content']['#item']-&gt;getValue()['target_id'])-&gt;getFileUri()


Or for a field with multiple items

foreach ($variables['items'] as $delta =&gt; $item) {
  $uri = \Drupal\file\Entity\File::load($variables['items'][$delta]['content']['#item']-&gt;getValue()['target_id'])-&gt;getFileUri()
}


And then apply an image style to get the url

$variables['banner_url'] = ImageStyle::load('image_style_name')-&gt;buildUrl($uri);