Hi,
I want to implement last articles on mi blog index.html with and image, and I have in front matter for each post a param:
img: img/test.png
I can show the image with this code:
{{ with .Site.GetPage "/blog" }}
{{ range first 4 .Pages }}
<div>
{{ $urlImg:= "" }}
{{ $permalink := .Permalink }}
{{ with .Params.img }}
{{ $urlImg = (printf "%s%s" $permalink .) }}
{{ end }}
<a href="{{.Permalink}}">
<img src="{{$urlImg}}">
<span>{{.Title}}</span>
</a>
</div>
{{ end }}
I have tried with this partial:
{{ partial "img.html" (dict "context" . "src" $urlImg ) }}
And trying to show the width of the image in the partial, but it doesn´t work.
{{ $src := .context.Page.Resources.GetMatch (printf "*%s*" .src) }}
{{ $src.Width }}
Any help please? I am new in Hugo. I have a shortcode for responsive images, but I can´t get the same in a partial.
Thanks a lot, best regards.