Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/2-REC/hugo-myportfolio-theme.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Severin <severinderek@gmail.com>2019-02-10 13:53:06 +0300
committerDerek Severin <severinderek@gmail.com>2019-02-10 13:53:06 +0300
commit43e5f5971006d59b58f81879cdc01dd9bbda03e7 (patch)
tree975dae72607acecd2b8f61d4029722187eab8a5c
parentefbd6a27f869a7b405479e1f2db6a7529cd19652 (diff)
Image gallery: Added caption & copyright handling
-rw-r--r--layouts/_default/single.html4
-rw-r--r--layouts/partials/gallery.html41
2 files changed, 40 insertions, 5 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index b4d3641..7fa2910 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -44,7 +44,9 @@
*/}}
{{ $images_directory := .Params.images_directory | default "images" }}
{{ $images_static := .Params.images_static | default "false" }}
- {{ partial "gallery.html" (dict "page" . "dir" $images_directory "static" $images_static) }}
+ {{ $images_copyright := .Params.images_copyright }}
+ {{ $images_params := .Params.images }}
+ {{ partial "gallery.html" (dict "page" . "dir" $images_directory "static" $images_static "images_params" $images_params "images_copyright" $images_copyright) }}
{{ partial "load-photoswipe.html" (dict "page" .) }}
{{ end }}
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\\.") }}<!-- is the current file a thumbnail image? -->
{{- $isimg := lower .Name | findRE "\\.(gif|jpg|jpeg|tiff|png|bmp)" }}<!-- is the current file an image? -->
{{- if and $isimg (not $isthumb) }}
- {{- $caption := .Name | replaceRE "\\..*" "" | humanize }}<!-- humanized filename without extension -->
+ {{ $name := .Name }}
+ {{ with $.images_copyright }}
+ {{ $.page.Scratch.Set "copyright" (print " - &copy; " .) }}
+ {{ end }}
+
+ {{ range $.images_params }}
+ {{ if eq .src $name }}
+ {{ with .title }}
+ {{ $.page.Scratch.Set "title" . }}
+ {{ end }}
+ {{ with .copyright }}
+ {{ $.page.Scratch.Set "copyright" (print " - &copy; " .) }}
+ {{ 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 }}<!-- absolute URL to hi-res image -->
{{- $thumb := .Name | replaceRE "(\\.)" ($thumbext | printf "%s.") }}<!-- filename of thumbnail image -->
{{- $thumbexists := where $files "Name" $thumb }}<!-- does a thumbnail image exist? -->
@@ -67,17 +99,18 @@ Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
<img itemprop="thumbnail" src="{{ if $thumbexists }}{{ $thumbURL }}{{ else }}{{ $linkURL }}{{ end }}" alt="{{ $caption }}" /><!-- <img> hidden if in .gallery -->
</div>
<figcaption>
- <p>{{ $caption }}</p>
+ <p>{{ $captionthumb }}</p>
</figcaption>
<a href="{{ $linkURL }}" itemprop="contentUrl"></a><!-- put <a> last so it is stacked on top -->
</figure>
</div>
+ {{ $.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.