Skip to content
Grav 2.0 is officially stable. Read the announcement →
Archive

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

Started by Muut Archive 10 years ago · 4 replies · 496 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 Deleted User, 9 years ago
0 1356 9 years ago
Archive · by Muut Archive, 9 years ago
2 936 9 years ago
Archive · by Muut Archive, 9 years ago
2 4066 9 years ago
Archive · by Muut Archive, 9 years ago
1 2954 9 years ago
Archive · by Muut Archive, 9 years ago
3 1120 9 years ago