Display resources’ title only if set in front matter

Hi all!

I would like to display the page resources’ titles, but only if changed via front matter.

Technically it is no problem. But is this really the correct way?

Thank you!

Front matter:

- src: 1.jpg
  title: My title

Layout file:

{{ range .Resources }}
  {{ if ne .Title .Name }}{{ .Title }}{{ end }}
{{ end }}