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

gitlab.com/VincentTam/huginn.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJustin Berthault <justin.berthault@zaclys.net>2018-02-11 20:08:23 +0300
committerJustin Berthault <justin.berthault@zaclys.net>2018-02-11 20:08:23 +0300
commitfcba9b0413bbb68324cceb930e42b84e5b48581d (patch)
tree0247063a12fa7bef551b037c4d4c412a274e0a28
parent0b02ed189e9f9a1c319bf2f83a46462bcbaa8231 (diff)
Rewrite Lightbox shortcode for .Resources feature
-rw-r--r--layouts/_default/single.html8
-rw-r--r--layouts/shortcodes/lightbox.html10
2 files changed, 11 insertions, 7 deletions
diff --git a/layouts/_default/single.html b/layouts/_default/single.html
index dcf5d84..8ec732e 100644
--- a/layouts/_default/single.html
+++ b/layouts/_default/single.html
@@ -1,8 +1,8 @@
{{- define "css" -}}
- {{ if isset .Params "lightbox" }}
+ {{- with .Resources.Match "images/lightbox/*.*" -}}
<link rel="stylesheet" href="/css/baguetteBox.min.css" />
{{- end -}}
- {{- with .Resources.ByType "image" -}}
+ {{- with .Resources.Match "images/gallery/*.*" -}}
<link rel="stylesheet" href="/css/baguetteBox.min.css" />
{{- end }}
<link rel="stylesheet" href="/css/pygments.min.css" />
@@ -63,14 +63,14 @@
{{ end }}
{{ end }}
{{- define "scripts" -}}
- {{- if isset .Params "lightbox" -}}
+ {{- with .Resources.Match "images/lightbox/*.*" -}}
<script src="{{ "js/baguetteBox.min.js" | relURL}}"></script>
<script>baguetteBox.run('a', {
captions: function(element) {
return element.getElementsByTagName('img')[0].alt;
}});</script>
{{- end -}}
- {{- with .Resources.ByType "image" -}}
+ {{- with .Resources.Match "images/gallery/*.*" -}}
<script src="{{ "js/baguetteBox.min.js" | relURL}}"></script>
<script>baguetteBox.run('.gallery', {
captions: function(element) {
diff --git a/layouts/shortcodes/lightbox.html b/layouts/shortcodes/lightbox.html
index f6f8beb..59729e3 100644
--- a/layouts/shortcodes/lightbox.html
+++ b/layouts/shortcodes/lightbox.html
@@ -1,4 +1,8 @@
-{{- $thumb := .Get "src" | default (printf "%s." ("-thumb") | replace (.Get "img") ".") }}
-<a href={{ .Get "img" }}>
- <img class="thumbnail {{ .Get "align" }}" src="{{ $thumb }}">
+{{ $img := (.Page.Resources.ByType "image").GetMatch ( printf "images/lightbox/%s*" (.Get "img")) }}
+{{ $align := (.Get "align") }}
+{{ .Scratch.Set "image" ($img.Resize "256x q80") }}
+{{ $scaled := .Scratch.Get "image" }}
+<a href="{{ $img.RelPermalink }}">
+ <img class="thumbnail {{ with $align }}{{ . }}{{ end }}" src="{{ $scaled.Permalink }}">
</a>
+