From 43e5f5971006d59b58f81879cdc01dd9bbda03e7 Mon Sep 17 00:00:00 2001 From: Derek Severin Date: Sun, 10 Feb 2019 17:53:06 +0700 Subject: Image gallery: Added caption & copyright handling --- layouts/partials/gallery.html | 41 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) (limited to 'layouts/partials/gallery.html') diff --git a/layouts/partials/gallery.html b/layouts/partials/gallery.html index ca77ac0..e8f2084 100644 --- a/layouts/partials/gallery.html +++ b/layouts/partials/gallery.html @@ -13,6 +13,17 @@ Input Parameters: - "thumb": String (suffix) - $.Get "thumb" => $.thumb (if defined, else "-thumb" by default) +(TODO: detail/document...) +- "images_copyright" +("MULTITEL") +- images: + - "src" +("1.png") + - "title" +("Plan") + - "copyright" +(...) + TODO: - .Get "caption-position" default "bottom" @@ -47,7 +58,7 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ {{- end -}} {{- $dir := $.page.Scratch.Get "dirURL" }} {{- $dirFiles := $.page.Scratch.Get "dirFiles" }} - {{ if (fileExists $dirFiles) -}} + {{- if (fileExists $dirFiles) -}} {{- $files := readDir $dirFiles }} {{- range $files -}} @@ -56,7 +67,28 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ {{- $isthumb := .Name | findRE ($thumbext | printf "%s\\.") }} {{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }} {{- if and $isimg (not $isthumb) }} - {{- $caption := .Name | replaceRE "\\..*" "" | humanize }} + {{ $name := .Name }} + {{ with $.images_copyright }} + {{ $.page.Scratch.Set "copyright" (print " - © " .) }} + {{ end }} + + {{ range $.images_params }} + {{ if eq .src $name }} + {{ with .title }} + {{ $.page.Scratch.Set "title" . }} + {{ end }} + {{ with .copyright }} + {{ $.page.Scratch.Set "copyright" (print " - © " .) }} + {{ end }} + {{ end }} + {{ end }} + + {{- $title := ($.page.Scratch.Get "title") | default (.Name | replaceRE "\\..*" "") }} + {{- $copyright := ($.page.Scratch.Get "copyright") | default "" }} + + {{- $captionthumb := $title }} + {{- $caption := (print $title $copyright) }} + {{- $linkURL := print $baseURL $dir "/" .Name | absURL }} {{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }} {{- $thumbexists := where $files "Name" $thumb }} @@ -67,17 +99,18 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/ {{ $caption }}
-

{{ $caption }}

+

{{ $captionthumb }}

+ {{ $.page.Scratch.Delete "title" }} + {{ $.page.Scratch.Delete "copyright" }} {{- end }} {{- end }} {{- end }} {{ $.page.Scratch.Delete "dirURL" }} {{ $.page.Scratch.Delete "dirFiles" }} - {{- else -}} {{/* TODO: Need to change the "figure" shortcode to a partial. -- cgit v1.2.3