Access media in collection

In making a Featured Posts display using the Mediator Skeleton/Theme, but am having issues accessing the correct image from each page. I set a featured_image-variable like this:
{% set featured_image = post.media.images|first %}, which I iterate through.

Each child-page sets metadata as such: image: X.extto refer to the featured image for the post. However, when accessing the featured image through {{ featured_image.url }}, Grav returns the first image it finds in the folder of the child-page, rather than the first image referred to in the page (post.md).

How can I return the url set directly in the posts’ metadata, rather than rely on the above variable which returns the incorrect image?

post.media.images is an array of all the images for a particular page. the |first filter is the just a way to get the first item from the array.

If you are looking for a specific image you should do something like this:

{% set featured_image = post.media.images[post.header.image] %}

Assuming your post page has a image: myimage.jpg type custom header.

I blindly assumed that the |firstfilter referred to the first image on the page, which would be what was set in the header (the other image displayed just by being existent in the folder).

What you suggested returned the image as expected. Good thing to note down for future use.