Width
返回给定图像资源的宽度。
调用 Width 方法之前,请先用 reflect.IsImageResourceWithMeta 函数确认 Hugo 能否确定图像尺寸。
{{ with resources.GetMatch "images/featured.*" }}
{{ if reflect.IsImageResourceWithMeta . }}
<img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}" alt="">
{{ else }}
<img src="{{ .RelPermalink }}" alt="">
{{ end }}
{{ end }}