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