Set a class to an img?


The picture shows up fine with the alt, it does not echo out the class when I view the source.
Any ideas?

{{ $img := resources.GetMatch (.Get “src”) }}

<img src=“{{ ($img.Resize “500x”).RelPermalink }}” {{ with .Get “alt” }}alt=“{{ . }}”{{ else }}alt=“” {{ with .Get “class” }}class=“{{ . }}”{{ else }}class=“”{{ end }}{{ end }}>

The “with class case” is nested inside the “NOT alt case”?

Worked, thanks. :slight_smile:

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