Hello, I’m having issues with image resources when using a json data file and receiving the error below.
<$image.RelPermalink>: nil pointer evaluating resource.Resource.RelPermalink
I do not receive this error when using page params instead of json data.
Code:
{{ $roster := getJSON .Params.roster }}
{{ range $roster }}
<div class="dropdown-container">
<header class="clearfix">
{{ with .Image }}
{{ $image := resources.GetMatch . }}
<img class="lazyload" data-object-fit="cover" src="{{ $image.RelPermalink }}" alt="{{ $.Name }}">
{{ end }}
<h3>{{ .Name }}</h3>
<figure class="expand">
<svg alt="" class="svg-icon" viewBox="0 0 20 20">
<path fill="none" d="M15.898,4.045c-0.271-0.272-0.713-0.272-0.986,0l-4.71,4.711L5.493,4.045c-0.272-0.272-0.714-0.272-0.986,0s-0.272,0.714,0,0.986l4.709,4.711l-4.71,4.711c-0.272,0.271-0.272,0.713,0,0.986c0.136,0.136,0.314,0.203,0.492,0.203c0.179,0,0.357-0.067,0.493-0.203l4.711-4.711l4.71,4.711c0.137,0.136,0.314,0.203,0.494,0.203c0.178,0,0.355-0.067,0.492-0.203c0.273-0.273,0.273-0.715,0-0.986l-4.711-4.711l4.711-4.711C16.172,4.759,16.172,4.317,15.898,4.045z"></path>
</svg>
</figure>
</header>
<article>
<div class="article-inner">
{{ with .Class }}
<p>Class: {{ . }}</p>
{{ end }}
{{ with .Highschool }}
<p>High School: {{ . }}</p>
{{ end }}
{{ with .Hometown }}
<p>Hometown: {{ . }}</p>
{{ end }}
{{ with .Position }}
<p>Position: {{ . }}</p>
{{ end }}
</div>
</article>
</div>
{{ end }}
Sample Data:
[
{
"No.": "01",
"Name": "Joe Smith",
"Class": "So",
"Highschool": "Pebble High School",
"Hometown": "Austin, TX",
"Position": "",
"B/T": "",
"Image": "/uploads/jsmith.jpg"
}
]