Skip to content
● Meet Grav Guard: keep every Grav site you run secure and up to date, all from one place. Free for up to 3 sites. Read more →

Missing something with page.media.images|first.url returning the second image?

Started by Muut Archive 10 years ago · 4 replies · 650 views
10 years ago

Hi all!

I was using the following code to automatically generate opengraph tag information for my header images:

TWIG
<meta name="og:image" property="og:image" content="http://www.gameprose.com{{ page.media.images|first.url }}" />

but I noticed that this actually ends up returning the second image uploaded to each page, consistently, rather than the first image. The weird thing about it is that I'm using the same type of code to pull in the first image as the header within the blog items themselves. Am I missing something with this?

Thanks for your time.

10 years ago

I think I remember a bug if I didn't add true parameter for url.
What does this output:

TWIG
{{ base_url_absolute }},{{ page.media.images|first.html.url(true) }}
10 years ago

Hey Paul thanks for the response. I'll give that a try this evening and get back to you 😁

10 years ago

Hey I just wanted to follow up and let you know that appears to have fixed the issue. Thanks again Paul!

Suggested topics

Topic Participants Replies Views Activity
Archive · by Muut Archive, 10 years ago
1 673 1 week ago
Archive · by Deleted User, 9 years ago
0 3043 9 years ago
Archive · by Muut Archive, 9 years ago
2 1983 9 years ago
Archive · by Muut Archive, 9 years ago
2 5337 9 years ago
Archive · by Muut Archive, 9 years ago
1 4134 9 years ago