@paul:
Take a look at this cookbook entry: https://learn.getgrav.org/cookbook/twig-recipes#displaying-an-image-uploaded-in-a-file-field
Example:
{{ page.media[header.yourfilefield|first.name] }}
@paul Yeah man I've been looking at this recipe and I don't think it addresses what I am asking. Currently I can pull everything from the header except the fields with upload functions. And it may be because of how my for loop is and/or the destination of the images.
If I was to simply do:
{% for feature in page.find('/events').children() %}
{{ feature.title }}
{% endfor %}
it outputs all the titles from each child page of the events folder, as expected. No issues.
But, it doesn't seem to pull the image file, path, name or anything from the field that I use to upload images....
header.overview.homepage_img:
type: file
destination: 'theme@:/images/featured'
style: vertical
size: medium
accept:
- 'image/*'
{% for feature in page.find('/events').children() %}
{{ feature.header.overview.homepage_img.name }}
{% endfor %}
The above twig code doesn't error out but it results to blank. And it should at least print out all the names of the image files right?
If I were to target just the field since its within the page header like so:
{% for feature in header.overview.homepage_img %}
{{ feature.name }}
{% endfor %}
This will pull the image name from the header...but that's not what I need. I'm trying to go through all the child pages of the events folder and pull the images from the field above. The field above is simplified for this question, but I'm only allowing one image to be uploaded to this field. I'm sure there is something simple I'm missing or overlooking.