How to get a taxonomy custom image field URL value I've created an image 'field_term_preview' field on the taxonomy vocabulary and trying to get this URL in my custom module:

$terms =\Drupal::entityTypeManager()-&gt;getStorage('taxonomy_term')-&gt;loadTree($vid, 0, null, true);

foreach ($terms as $term) {
    if ($term-&gt;getName = 'Term with preview')
    {
        foreach ($term-&gt;getFields(true) as $field)
        {
            if ($field-&gt;getName() == 'field_term_preview')
            {
                var_dump($field-&gt;getValue());
            }
        }
    }
}


This code shows only target_id, alt, height, etc.


How to get the URL to the preview image?
In Drupal images are File entities, the target_id is the File ID. So...

$fid = $field-&gt;getValue()[0]['target_id']; // File ID, 

// Note the [0] in the array. We assume there is always going to be 1 image here. 
// If your field allows more than 1 image, you will need to loop through each $field-&gt;getValue()

$file = \Drupal\file\Entity\File::load($fid); // load File entity object

$file_url = $file-&gt;url(); // get the URL.