Issues processing images from bundles

Hi all,

In previous projects I’ve stored all images in a single assets directory. However, I’ve recently switched to storing images along with posts, as I believe is recommended, but now I’m having problems processing images; resize doesn’t find the image!


I’d like to:

  • return them in that order, and
  • make them available for processing in a partial

I suspect the issue is with this line in my image partial, but not sure tbh!

{{- $src := .Resources.GetMatch (printf "**%s" ($img)) -}}

Hoping someone can point me in the right direction and / or offer advice on how I can make improvements. Tia!

You are passing this context to the image partial: alt, path, and imgClass.

But in the partial you are using Resources.GetMatch, a method on a Page object.

So you need to include the page in the context.

Thanks @jmooring . Is there a better option to achieve what I’m trying to do?


{{ partial "image" (dict
  "alt" .alt
  "img" .path
  "imgClass" "bg-cover"
  "page" $
) }}


{{- $src := .page.Resources.GetMatch (printf "**%s" ($img)) -}}
1 Like

Amazing. Thank you so much for your help @jmooring

1 Like

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