Help with error: Param is not a method but has arguments

I’m receiving this error with the below code. It uses Hyas images, which is based on Hugo responsive images.

Any idea how to make this work?

{{ $image := "" }}
{{ if .Params.additional_images }}
    {{ range $index, $val := $.Params.additional_images }}
        {{ $image = $.Resources.Get .src }}
        {{ if $image }}
                {{ partial "picture" (dict
                "ctx" .
                "src" $image.RelPermalink
                "alt" .alt
                "class" "my-classes"
                )}}
        {{ end }}
    {{ end }}
{{ end }}

My front matter contains a YAML array with the following structure:

additional_images:
  - src: image1.jpg
    alt: "image 1 alt text"

I suspect you have a context problem…

{{ partial "picture" (dict
  "ctx" .
  "src" $image.RelPermalink
  "alt" .Title
  "class" "my-classes"
)}}

Does the “picture” partial expect ctx to be a map from your front matter, or does it want a page? Because right now you are passing a map with keys src and alt.

Also, within your iteration, .Title isn’t a thing.

1 Like

Honesty, I have no idea what ctx is or how it works… it’s all magic to me. I’m using this module successfully in other places, where the image source in front matter is a simple key:value pair, image: image1.jpg.

I’m only struggling to make it work when the image source is in a front matter array like this.

Appreciate your reply and wish I could provide a better answer.

Also, within your iteration, .Title isn’t a thing.

My bad… updated.

I suggest you contact the author for assistance:
https://github.com/gethyas/images/issues

1 Like