mirror of
https://github.com/gohugoio/hugo.git
synced 2025-08-22 21:42:50 +02:00
tpl: Add imageConfig function
Add imageConfig function which calls image.DecodeConfig and returns the height, width and color mode of the image. (#2677) This allows for more advanced image shortcodes and templates such as those required by AMP. layouts/shortcodes/amp-img.html ``` {{ $src := .Get "src" }} {{ $config := imageConfig (printf "/static/%s" $src) }} <amp-img src="{{$src}}" height="{{$config.Height}}" width="{{$config.Width}}" layout="responsive"> </amp-img> ```
This commit is contained in:
committed by
Bjørn Erik Pedersen
parent
950034db5c
commit
a49f838cd0
@@ -120,12 +120,14 @@ func (h *HugoSites) getNodes(nodeID string) Nodes {
|
||||
return Nodes{}
|
||||
}
|
||||
|
||||
// Reset resets the sites, making it ready for a full rebuild.
|
||||
// Reset resets the sites and template caches, making it ready for a full rebuild.
|
||||
func (h *HugoSites) reset() {
|
||||
h.nodeMap = make(map[string]Nodes)
|
||||
for i, s := range h.Sites {
|
||||
h.Sites[i] = s.reset()
|
||||
}
|
||||
|
||||
tpl.ResetCaches()
|
||||
}
|
||||
|
||||
func (h *HugoSites) reCreateFromConfig() error {
|
||||
|
Reference in New Issue
Block a user