I am new to Grav, but I was attracted by its Twig simplicity.
I have the following newbie question: I imported a theme "Multiverse", that I want to change slightly. Why "page.media[image.thumbnail].url" works and "page.media[image.flag].url" returns blank, even if defined in YAML?
Multiverse blueprint.yaml in Admin:
title: Gallery
'@extends':
type: default
form:
fields:
tabs:
type: tabs
active: 1
fields:
images:
type: tab
title: Images
fields:
header.images:
name: images
type: list
label: Images
fields:
.title:
type: text
label: Title
help: Image's title.
.thumbnail:
type: text
label: Thumbnail
help: Thumbnail's filename.
.description:
type: text
label: Description
help: Image's description.
.flag:
type: text
label: Flag
help: Flag.
.keywords:
type: text
label: Keywords
help: Keywords.
Then, in home.twig of Multiverse, I have:
{% for image in page.header.images %}
<article class="thumb">
<a href="{{ page.media[image.thumbnail].url }}" class="image">
<img src="{{ page.media[image.thumbnail].url }}" alt="{{ image.title|escape }}" />
</a>
<h2>{{ image.title|raw }}</h2>
<p>{{ image.description|raw }}</p>
<img src="{{ page.media[image.flag].url }}" alt="{{ image.keywords|escape }}" />
</article>
{% endfor %}
So, I only added this line:
<img src="{{ page.media[image.flag].url }}" alt="{{ image.keywords|escape }}" />
I added values for all fields in Admin Expert mode in Images tab:
title: 'Armenia (Asia)'
thumbnail: khor-virap-1781518.jpg
description: 'Țara muntelui Ararat, unde se zice că s-a oprit arca lui Noe și cu prima biserică creștină fondată în secolul I.'
flag: ar.png
color: blue
keywords: Europe
ribbon: LUX
stars: '2'
As you can see, both "thumbnail" and "flag" are defined in blueprint and in media. Both images are uploaded in the folder:
thumbnail: khor-virap-1781518.jpg
flag: ar.png
Why page.media[image.thumbnail].url returns the url correctly: /user/pages/01.home/khor-virap-1781518.jpg, but page.media[image.flag].url returns blank?
Is "thumbnail" some kind of special field? I see it defined as text:
.thumbnail:
type: text
label: Thumbnail
help: Thumbnail's filename.
Thank you!
What is confusing is that all fields that I added, like keywords, ribbon, even flag, work if I output them:
{{ image.flag }} works {{ image.flag.url }} doesn't work {{ page.media[image.flag].url }} doesn't work