From 6cc5bb33a1785a6069e6c9aa6612c8947e017915 Mon Sep 17 00:00:00 2001 From: FarseaSH Date: Sat, 9 Apr 2022 17:49:51 +0800 Subject: [PATCH 1/2] FEATURE: picure caption test --- layouts/partials/pic_set.html | 5 ++++- layouts/partials/row.html | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/layouts/partials/pic_set.html b/layouts/partials/pic_set.html index b4d66aa..667d6c6 100644 --- a/layouts/partials/pic_set.html +++ b/layouts/partials/pic_set.html @@ -1,17 +1,20 @@ +{{ $caption := .other }} + {{ $num_per_row := 3}} {{ $max_width := 80}} {{ if or (eq (len .pic_set) 2) (eq (len .pic_set) 4)}} {{ $num_per_row = 2}} {{ $max_width = 53}} {{ end }} +
{{ range $num, $a := .pic_set }}
diff --git a/layouts/partials/row.html b/layouts/partials/row.html index 752a025..ca8e342 100644 --- a/layouts/partials/row.html +++ b/layouts/partials/row.html @@ -93,8 +93,13 @@ {{ end }} {{ end }} + {{ $test := "test" }} {{ if (gt (len $pictures_set) 1)}} - {{ partial "pic_set.html" (dict "pic_set" $pictures_set) }} + {{/* partial "pic_set.html" (dict "pic_set" $pictures_set "other" $.Site.BaseURL) */}} + {{ partial "pic_set.html" (dict "pic_set" $pictures_set "other" $.Site.BaseURL) }} + {{ $test }} + {{ partial "pic_set.html" (dict "pic_set" $pictures_set "other" $.Site.BaseURL) }} + {{/* partial "pic_set.html" $pictures_set "other" */}} {{ end }} From d5904ec528881920183801abf55416de74c52af0 Mon Sep 17 00:00:00 2001 From: FarseaSH Date: Sun, 4 Sep 2022 21:14:31 +0800 Subject: [PATCH 2/2] FEATURE: Add caption under pictures in the fancybox mode --- layouts/partials/pic_set.html | 2 ++ layouts/partials/row.html | 18 +++++++----------- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/layouts/partials/pic_set.html b/layouts/partials/pic_set.html index 7a39b01..ad8aedd 100644 --- a/layouts/partials/pic_set.html +++ b/layouts/partials/pic_set.html @@ -5,6 +5,8 @@ {{ $max_width = 53}} {{ end }} +{{ $caption := .caption}} +
{{ range $num, $a := .pic_set }} diff --git a/layouts/partials/row.html b/layouts/partials/row.html index 5723031..f49d3e5 100644 --- a/layouts/partials/row.html +++ b/layouts/partials/row.html @@ -61,7 +61,8 @@ {{/* add-on info 1: pictures */}} {{/* new pictures API `pictures` (combine single & multiple pictures)*/}} - {{ $pictures_set:= slice}} + {{ $pictures_set := slice}} + {{ $picture_caption := .Plain}} {{ with .Params.pictures }} {{ range . }} {{ with . }} @@ -72,25 +73,20 @@ {{ if (eq (len $pictures_set) 1) }} {{ range $pictures_set }} - Responsive image + Responsive image {{ end }} {{ end }} - {{ $test := "test" }} {{ if (gt (len $pictures_set) 1)}} - {{/* partial "pic_set.html" (dict "pic_set" $pictures_set "other" $.Site.BaseURL) */}} - {{ partial "pic_set.html" (dict "pic_set" $pictures_set "other" $.Site.BaseURL) }} - {{ $test }} - {{ partial "pic_set.html" (dict "pic_set" $pictures_set "other" $.Site.BaseURL) }} - {{/* partial "pic_set.html" $pictures_set "other" */}} + {{ partial "pic_set.html" (dict "pic_set" $pictures_set "other" $.Site.BaseURL "caption" $picture_caption) }} {{ end }} {{/* Probably DEPRECATED in the future: single picture (old version API `pic`)*/}} {{ with .Params.pic }} - Responsive image + Responsive image {{ end }} - {{/* Probably DEPRECATED: multiple pictures (old version API `pic_set`) */}} + {{/* Probably DEPRECATED in the future: multiple pictures (old version API `pic_set`) */}} {{ $pic_set_filtered := slice}} {{ with .Params.pic_set }} {{ range . }} @@ -101,7 +97,7 @@ {{ end }} {{ with $pic_set_filtered }} - {{ partial "pic_set.html" (dict "pic_set" .) }} + {{ partial "pic_set.html" (dict "pic_set" . "caption" $picture_caption) }} {{ end }}