HUGO
Menu
GitHub 87548 stars Mastodon

Width

适用于图像,返回给定资源的宽度。

Syntax

RESOURCE.Width

Returns

int

此方法可用于 全局资源页面资源远程资源

{{ with resources.Get "images/a.jpg" }}
  {{ .Width }} → 600
{{ end }}

渲染 img 元素时一起使用 WidthHeight 方法:

{{ with resources.Get "images/a.jpg" }}
  <img src="{{ .RelPermalink }}" width="{{ .Width }}" height="{{ .Height }}">
{{ end }}

Last updated: January 1, 0001
Improve this page