add caption on slideshow and lightbox
This commit is contained in:
@@ -20,11 +20,7 @@ Automagical css image gallery in [Hugo](https://gohugo.io/) using shortcodes. Li
|
|||||||
- CSS and JS is automatically loaded the first time you use the `{{< snap-gallery >}}` shortcode on each page
|
- CSS and JS is automatically loaded the first time you use the `{{< snap-gallery >}}` shortcode on each page
|
||||||
- Multiple galleries/slideshows per page supported, no interference
|
- Multiple galleries/slideshows per page supported, no interference
|
||||||
- Automatic rotation of slideshow with a configurable interval. Can also be disabled.
|
- Automatic rotation of slideshow with a configurable interval. Can also be disabled.
|
||||||
- Supports providing metadata such as `alt` and `title` attributes
|
- Supports providing metadata such as `alt` and `title` attributes as well as captions
|
||||||
|
|
||||||
### Roadmap / untested
|
|
||||||
|
|
||||||
- Captions
|
|
||||||
|
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|||||||
@@ -82,7 +82,12 @@ $gap: var(--gap);
|
|||||||
/* stretch line height */
|
/* stretch line height */
|
||||||
height: 100%;
|
height: 100%;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Disable cursor selection in lightbox and on slideshow, especially controls
|
||||||
|
.snap-lightbox,
|
||||||
|
.snap-slideshow {
|
||||||
|
user-select: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
// /* Click on the complete background closes the lightbox */
|
// /* Click on the complete background closes the lightbox */
|
||||||
@@ -111,29 +116,42 @@ $gap: var(--gap);
|
|||||||
max-height: 100%;
|
max-height: 100%;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Untested
|
|
||||||
p {
|
|
||||||
color: #fff;
|
|
||||||
z-index: 810;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 767px) {
|
@media screen and (max-width: 767px) {
|
||||||
max-width: 80%;
|
max-width: 80%;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Number text (1/3 etc) */
|
/* Number text (1/3 etc) and captions*/
|
||||||
.snap-lightbox,
|
.snap-numbertext {
|
||||||
.snap-slideshow {
|
position: absolute;
|
||||||
user-select: none;
|
|
||||||
|
|
||||||
.numbertext {
|
|
||||||
color: #f2f2f2;
|
color: #f2f2f2;
|
||||||
background-color: #000;
|
background-color: #000;
|
||||||
font-size: 12px;
|
font-size: 12px;
|
||||||
padding: 8px 12px;
|
padding: 8px 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.snap-caption {
|
||||||
|
bottom: 0;
|
||||||
|
color: #f2f2f2;
|
||||||
|
padding: 8px 0;
|
||||||
|
left: 10%;
|
||||||
|
width: 80%;
|
||||||
|
text-shadow: 1px 1px 10px #000;
|
||||||
|
font-weight: 700;
|
||||||
|
font-size: 1.1em;
|
||||||
|
text-align: center;
|
||||||
|
|
||||||
|
// As slideshow, position on picture on mid-screens and wider
|
||||||
|
.snap-slideshow & {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
|
|
||||||
|
@media screen and (max-width: 767px) {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// In lightbox, always show below picture
|
||||||
|
.snap-lightbox & {
|
||||||
|
position: relative;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -3,13 +3,16 @@
|
|||||||
<div class="snap-lightbox" id="snap-lightbox-{{ $galno }}">
|
<div class="snap-lightbox" id="snap-lightbox-{{ $galno }}">
|
||||||
{{- range $i, $img := $imgs }}
|
{{- range $i, $img := $imgs }}
|
||||||
<div class="snap-lightbox-inner">
|
<div class="snap-lightbox-inner">
|
||||||
<div class="numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>
|
<div class="snap-numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>
|
||||||
<img
|
<img
|
||||||
src="{{ relURL $img.src }}"
|
src="{{ relURL $img.src }}"
|
||||||
{{ range $attr, $value := $img.html -}}
|
{{ range $attr, $value := $img.html -}}
|
||||||
{{ safeHTMLAttr $attr }}={{ $value }}
|
{{ safeHTMLAttr $attr }}={{ $value }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
/>
|
/>
|
||||||
|
{{- with $img.html.title }}
|
||||||
|
<div class="snap-caption">{{ . }}</div>
|
||||||
|
{{- end }}
|
||||||
</div>
|
</div>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
@@ -18,9 +21,4 @@
|
|||||||
|
|
||||||
<a class="snap-prev" onclick="moveLightboxItem({{ $galno }}, -1)"><span>❮</span></a>
|
<a class="snap-prev" onclick="moveLightboxItem({{ $galno }}, -1)"><span>❮</span></a>
|
||||||
<a class="snap-next" onclick="moveLightboxItem({{ $galno }}, 1)"><span>❯</span></a>
|
<a class="snap-next" onclick="moveLightboxItem({{ $galno }}, 1)"><span>❯</span></a>
|
||||||
|
|
||||||
{{/* <!-- Caption text -->
|
|
||||||
<div class="caption-container">
|
|
||||||
<p id="caption"></p>
|
|
||||||
</div> */}}
|
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -3,7 +3,10 @@
|
|||||||
<div class="snap-slideshow" id="snap-slideshow-{{ $galno }}" style="--columns:1;--min-width:0px;--gap:0px;--slideshow-width:{{ default "100%" .width }};--cursor:{{ .cursor }};--aspectratio:{{ safeCSS (default "16/10" .aspectratio) }};">
|
<div class="snap-slideshow" id="snap-slideshow-{{ $galno }}" style="--columns:1;--min-width:0px;--gap:0px;--slideshow-width:{{ default "100%" .width }};--cursor:{{ .cursor }};--aspectratio:{{ safeCSS (default "16/10" .aspectratio) }};">
|
||||||
{{- range $i, $img := $imgs }}
|
{{- range $i, $img := $imgs }}
|
||||||
<div class="snap-image">
|
<div class="snap-image">
|
||||||
<div class="numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>
|
<div class="snap-numbertext">{{ add $i 1 }} / {{ len $imgs }}</div>
|
||||||
|
{{- with $img.html.title }}
|
||||||
|
<div class="snap-caption">{{ . }}</div>
|
||||||
|
{{- end }}
|
||||||
<img
|
<img
|
||||||
src="{{ relURL $img.src }}"
|
src="{{ relURL $img.src }}"
|
||||||
{{ range $attr, $value := $img.html -}}
|
{{ range $attr, $value := $img.html -}}
|
||||||
|
|||||||
Reference in New Issue
Block a user