Based on the docs, I have the following code to process with the first image of a bundle page:
{{ range first 1 (.Resources.ByType "image") }}<img src="{{ .RelPermalink }}" alt="{{ .Title }}">
{{ end }}
It works fine but I am wondering whether it’s a more convenient way to achieve that, i.e. having a frontmatter parameter such as cover : image.jpg to select only the cover image.
Thanks
Thanks, but it seems not working. I added cover: image.jpg in frontmatter
Just wondering why it needs to have both {{ with .Params.cover }} and {{ with $.Resources.GetMatch . }}
The code is fine. If you are still having problems please post a link to the repository for your project, or to a repository that demonstrates the problem.
The outer conditional (with .Params.Cover) verifies that the cover paramater was set in front matter.
The inner conditional ($.Resources.GetMatch .) verifies that the resource exists.