Error: .Fill can't evaluate field Fill in type string

Getting this error when trying to use the image processing .Fill method. I’ve been trying to solve this for about 3 hours now. I’m using the latest Hugo version. Please help.

“…execute of template failed: template: …single.html:82:41: executing “main” at <.Fill>: can’t evaluate field Fill in type string”

Frontmatter:

---
gallery:
- "/uploads/image-1.jpg"
- "/uploads/image-2.jpg"
---

single.html

{{ $gallery := .Params.gallery }}
{{ if gt ( len $gallery) 0 }}
    <ul>
    {{ range $gallery }}
        <li>
            <a href="{{ . | relURL }}">
                {{ $thumb := (.Fill "150x150 Top") }}
                <img src="{{ $thumb | relURL }}">
            </a>
        </li>
    {{ end }}
    </ul>
{{ else }}
    no images
{{ end }}

Well, ^ that is a string. Try pattern matching the string to get a reference to the resource, then use .Fill.

Thank you @pointyfar. I used pattern matching per your suggestion and fixed it. Here’s my solution:

{{ $path := $.Site.GetPage "section" "uploads" }}
{{ $imageFile := $path.Resources.GetMatch (strings.TrimPrefix "/uploads/" . ) }}
{{ $thumb := $imageFile.Fill "150x150 Top" }}
<img src="{{ $thumb.RelPermalink }}"> 

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.