I want to add width="xxx" and height="xxx" in my figure.html.
So having Page Bundles, cannot find right way.
First attempt:
{{/* OK */}}
{{ $img1 := .Get "src"}}
{{/* OK */}}
{{ $img2 := .Page.RelPermalink }}
{{/* OK */}}
{{ $imgFile := path.Join "/" $img1 $img2 }}
{{/* OK */}}
{{ with imageConfig ( $imgFile) }}
Hugo add /img/ in the path and throw error.
domain-path \img \slug
Found code in forum with .Destination… but Hugo throw error.
Surprising, with this code no error:
{{ with imageConfig ( $imgFile ) }}
{{ $width= .Width }}
{{$height = .Height }}
{{ end }}
But getting this code in <img tag:
{{ with imageConfig ( $imgFile ) }}
width="{{ .Width }}"
height="{{ .Height }}"
{{ end }}
Hugo throw error because insert /img/ string in path.
update:
{{ $img2 := $.Page.Resources.GetMatch (.Get "src") }}
{{ with imageConfig ( $img2 ) }}
{{ end }}
throw error:
failed to render shortcode "figureh": failed to process shortcode: execute of template failed at <imageConfig ($img2)>: error calling imageConfig: config needs a filename
A resource in a page what else is supposed to be other than a file?
So how to obtain image width and height suitable for figure shortcut?
Please provide a link to a public repository or a reproducible test case repository as per Requesting Help.
At a guess the .jpg is corrupted or not actually a jpeg.