Accessing selected file from files as URL

From this blueprint:

      width: 2/3
        # we need a field section here
          type: fields
           # a files field to select an image
              label: Featured Image # fields have labels, not headlines
              type: files
              max: 1

I would like to echo the featured image’s URL. The idea is that the editor uploads all images from the project and then selects one from the group to show as featured image.

The file name is being printed on the project.txt file, and I can echo it, but I cannot turn it into a URl so that it can be embedded as source. What am I doin wrong?

I have tried:


and many other configuration, yet I cant access the URL :frowning:

if ($image = $page->featured()->toFile()) {
  echo $image->url();

I get an error with this code

<?php foreach ($page->children()->listed()->sortBy('year', 'desc') as $works) : ?>
    <div class="col-xs-12 col-sm-6 col-md-4 py-4 work-ft">
        <a href="<?= $works->url() ?>">
            <img class="img-fluid work-ft-img " src="<?= 
            if ($image = $works->featured()->toFile()) {
                echo $image->url();
        <?= $works->title()->upper() ?>
        <div class="<?= $works->year() ?>">
            <?= $works->year() ?>

    <?php endforeach ?>

$image = $works->featured()->toFile()

prints the file name, but when i try


I get an error. I tried with different variables names, but still the same…

Your syntax is wrong

<?php if ($image = $page->featured()->toFile()): ?>
    <img class="img-fluid work-ft-img " src="<?= $image->url() ?>">
<?php endif ?>


Oh woops yes, sry php is not my forte.

Thanks so much for your help @texnixe !!!