Adding custom media header file to page

Big fan of Grav, usually can figure out any problems but this one has me stuck.

I added a custom blueprint for a singular image upload that will be referenced on a page. This is how it looks in the header of that file. The image upload is titled simply as ‘icon’.

Screen Shot 2017-05-01 at 20

I am trying to output some of its values like this: {{ page.custom.icon.name }} or even {{ page.header.custom.icon.name }}

Thanks so much in advance, this is a fantastic CMS and can’t wait to launch a website on it.

Hi,
From looking at your screenshot, you would have to write this to retrieve the values:

{{ page.header.custom.icon.user/pages/05.work/06.test/eastronlogo.png.nam e }}

But I don’t think that’s what you want :slight_smile: And I’m not sure if it would work with the slashes…
What does your blueprint for the image look like?

Hi Ben thanks for the reply, I was afraid that the only way I could retrieve them was with hardcoded paths if it was done this way. As I am adding these as blog posts they will differ every time. Attached what the blueprint looks like below, I might have missed something important there as I am relatively new to using blue prints and adding custom fields.

Screen Shot 2017-05-02 at 07

Thanks again for the help.

Sorry, I was wrong before… your blueprint looks correct.
The way to retrieve the values of the image is like:

{% for key, item in page.header.custom.icon %}
    <img src="{{ url(item.path) }}" alt="{{ item.name }}" />
{% endfor %}

Hope this works!

It works.So nice of you.Thank you.

Glad I could help!
Happy programming :wink:

Thanks a lot Ben, it seems someone else had a similar problem as me was thanking you there, but just like them your solution works marvelously. Though I do wonder if there is a more elegant way of not needing to use a for loop for this, just for a little bit better performance, that being said we are talking fractions of milliseconds when talking about running it 10-14 times. Either way thanks so much, you rock!