support providing a metadata file
This commit is contained in:
@@ -18,6 +18,12 @@
|
||||
{{- $imgs := slice -}}
|
||||
{{- $img_exts := slice ".jpg" ".jpeg" ".png" ".gif" ".webp" ".tiff" -}}
|
||||
|
||||
{{/* Get information from optional metadata file */}}
|
||||
{{- $metadata := dict -}}
|
||||
{{- with .Params.metadata -}}
|
||||
{{- $metadata = index $.Site.Data . -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Get images from src Param, separated by comma */}}
|
||||
{{- range (split .Params.src ",") -}}
|
||||
{{- $img := (trim . " ") -}}
|
||||
@@ -36,10 +42,19 @@
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/* Filter collected files by whether they are an image. Throw others out */}}
|
||||
{{/* Filter collected files, store them as slice of dicts/maps */}}
|
||||
{{- range $imgs_collect -}}
|
||||
{{/* Only process files if they are recognised as an image */}}
|
||||
{{- if in $img_exts (lower (path.Ext .)) -}}
|
||||
{{- $imgs = $imgs | append . -}}
|
||||
{{/* Create a dict holding path and optional metadata */}}
|
||||
{{- $imgdict := dict "src" . -}}
|
||||
{{/* If metadata for this image path found, add all of it to dict */}}
|
||||
{{- $img_metadata := where $metadata "src" . -}}
|
||||
{{- with $img_metadata -}}
|
||||
{{- $imgdict = merge $imgdict (index . 0) -}}
|
||||
{{- end -}}
|
||||
{{/* Add final dict to slice */}}
|
||||
{{- $imgs = $imgs | append $imgdict -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
@@ -63,6 +78,6 @@
|
||||
{{- end -}}
|
||||
|
||||
{{/* The Modal/Lightbox */}}
|
||||
{{- if $lightbox -}}
|
||||
{{ if $lightbox -}}
|
||||
{{- partial "lightbox" (dict "galno" $galno "imgs" $imgs) -}}
|
||||
{{- end -}}
|
||||
|
||||
Reference in New Issue
Block a user