Skip to content
Grav 2.1 is out: every page speaks Markdown. Read the announcement →

Call hero image from parent blog page to post

Solved by Jayesh Gohel View solution

Started by Pedro Oliveira 7 years ago · 2 replies · 592 views
7 years ago

Hi,

I need to show the hero image from blog main page in the children posts.
I can call the first image in the page media, with:

{% set page = page.find('/news') %}
{% set hero_image = page.media.images|first %}

But what I need is to call the selected image in the hero_image field.
The line below doesn't work.

{% set hero_image = page.header.hero_image %}

What am i missing?..
Any help is appreciated.

Thanks
Pedro

7 years ago Solution

You can try page.media.images[page.header.hero_image].

Suggested topics

Topic Participants Replies Views Activity
Support · by Marcel, 5 days ago
0 85 5 days ago
Support · by JakobDB, 6 days ago
1 91 6 days ago
Support · by ramenos, 7 days ago
3 103 6 days ago
Support · by gravinator, 2 weeks ago
3 229 7 days ago
Support · by Roger Parkinson, 2 weeks ago
3 308 2 weeks ago