diff --git a/wowchemy/layouts/_default/_markup/render-image.html b/wowchemy/layouts/_default/_markup/render-image.html new file mode 100644 index 00000000..31375355 --- /dev/null +++ b/wowchemy/layouts/_default/_markup/render-image.html @@ -0,0 +1,72 @@ +{{/* Markdown Image Renderer for Wowchemy. */}} +{{/* Load image from page dir falling back to media library at `assets/media/` and then to remote URI. */}} + +{{ $destination := .Destination }} +{{ $is_remote := strings.HasPrefix $destination "http" }} +{{ $caption := .Title | default "" }} +{{ $zoom := "true" }} +{{ $id := anchorize ($caption | plainify) }} +{{ $alt := .Text | default ($caption | plainify) }} +{{ $img_class := "" }} +{{ $fig_class := "" }} +{{ $max_width := "" }} +{{ $width := "" }} +{{ $height := "" }} +{{ $numbered := false }} + +{{/* Workaround Hugo v0.81 error on Windows when `resources.Get (path.Join "media" )` */}} +{{- $img := "" -}} +{{- if not $is_remote -}} + {{- $img = (.Page.Resources.ByType "image").GetMatch $destination -}} + {{- if not $img -}} + {{- $img = resources.Get (path.Join "media" $destination) -}} + {{- end -}} +{{- end -}} + +
+
+
+ {{- if $img -}} + {{- $isSVG := eq $img.MediaType.SubType "svg" -}} + {{- $isGIF := eq $img.MediaType.SubType "gif" -}} + {{- if $isSVG | or $isGIF -}} + {{ $alt }} + {{- else }} + {{- $img_lg := $img.Fit "1200x1200" -}} + {{- $img_md := $img_lg.Fit "760x760" -}}{{/* Match `.docs-article-container` max-width */}} + {{- $img_sm := $img_md.Fit "400x400" -}} + {{- $width := $width | default $img_md.Width -}} + {{- $height := $height | default $img_md.Height -}} + {{ $alt }} + {{- end }} + {{- else -}} + {{ $alt }} + {{- end -}} +
+
+ + {{- if $caption -}} + {{/* Localize the figure numbering (if enabled). */}} + {{- $figure := split (i18n "figure" | default "Figure %d:") "%d" -}} + + {{ $caption | markdownify | emojify }} + + {{- end -}} +