Image processing error due to hidden .DS_Store file

I am processing images through .Resources.GetMatch, but after upgrading Hugo to version 0.57.2 (before it was 0.55.x) it is giving errors due to .DS_Store files. Below is the code snippet:

{{ with .Resources.GetMatch "images/*" }}
<img src="{{ (.Fill "380x380 q80").Permalink }}">
{{ end }}

This code snippet returns the following error when there is a .DS_Store file inside the /images folder:

execute of template failed: template: blog/single.html:39:67: executing "main" at <"images/*">: can't evaluate field Fill in type resource.Resource

Does anyone know how to solve this problem?

I think I stumbled on this issue myself and will create and issue and fix it. What you can do is to add an extension to the filter, e.g.

{{ with .Resources.GetMatch "images/*.*" }}

If the above does not work, you may need to be more specific, e.g.

{{ with .Resources.GetMatch "images/*.*p*" }}

The above would match jpg, png etc.

You could also do:

{{ with (.Resources.ByType "image").GetMatch "images/*" }}
2 Likes

You are the one! Thank you!