Hi,
I try to modify the image render hook to automatically add a figure / figcaption html element around, with a legend field the width of the picture, and its height growing to accomodate the legend’s text.
But clearly I’m biting more than I can chew, because 1) I don’t get any of that non-html code 2) it fails.
I put the css code elsewhere, and it shouldn’t matter now.
Voir le code de themes/hugo-book/layouts/_default/_markup/render-image.html
{{- if .Page.Site.Params.BookPortableLinks -}} {{- template "portable-image" . -}} {{- else -}}
{{ with .Title }} {{.Title}} {{ end }}
{{- end -}}
{{- define “portable-image” -}}
{{- $isRemote := or (in .Destination “://”) (strings.HasPrefix .Destination “//”) }}
{{- if not $isRemote }}
{{- $path := print .Page.File.Dir .Destination }}
{{- if strings.HasPrefix .Destination “/” }}
{{- $path = print “/static” .Destination }}
{{- end }}
{{- if not (fileExists $path) }}
{{- warnf “Image ‘%s’ not found in ‘%s’” .Destination .Page.File }}
{{- end }}
{{- end }}
{{ with .Title }} {{.Title}} {{ end }}
{{- end -}}The error messages:
Error: Error building site: "/home/drm/WEBSITE/content/_index.md:19:1": failed to render shortcode "center": failed to process shortcode: "/home/drm/WEBSITE/themes/hugo-book/layouts/shortcodes/center.html:2:19": execute of template failed: template: shortcodes/center.html:2:19: executing "shortcodes/center.html" at <.Page.RenderString>: error calling RenderString: "/home/drm/WEBSITE/content/_index.md:1:1": "/home/drm/WEBSITE/themes/hugo-book/layouts/_default/_markup/render-image.html:4:38": execute of template failed: template: _default/_markup/render-image.html:4:38: executing "_default/_markup/render-image.html" at <.Title>: can't evaluate field Title in type string Built in 1756 msI thought it would suffice to copy “{{ with .Title }} {{.Title}} {{ end }}” inside the figcaption tag (to act the legend), why does it not ?!
Thanks