ccchh-website/themes/ccchh/layouts/_default/_markup/render-image.html
jtbx e4ff96aee2 Add shortcode to place resized images + fix md image for non-pagebundles
If a page is not a page bundle, it can't access files in the same
directory via the .Resources variable. So we need to detect this
condition and get the image file in another way.
2023-10-11 23:29:06 +02:00

17 lines
503 B
HTML

{{- $imagename := .Destination }}
{{- $text := .Text }}
{{- $title := .Title }}
{{- $isBundle := ne .Page.BundleType "" }}
{{- $page := .Page }}
{{- if not $isBundle }}
{{ $page_dir := path.Dir .Page.File }}
{{ $pagebundle_path := path.Join "/" $page_dir }}
{{ $page = .Page.Site.GetPage $pagebundle_path }}
{{- end -}}
{{- with $page.Resources.Get $imagename }}
<p class="md-img">
<img src="{{ .RelPermalink }}" alt="{{ $text }}" {{ with $title }} title="{{ . }}"{{ end }} />
</p>
{{- end }}