feat(image): add image lightgallery
This commit is contained in:
@@ -1,3 +1,36 @@
|
||||
{{- /* Lazyload */ -}}
|
||||
{{- $res := resources.Get "svg/loading.svg" | minify -}}
|
||||
<img src="{{ $res.RelPermalink | safeURL }}" data-sizes="auto" data-src="{{ index . `src` | safeURL }}" alt="{{ index . `alt` }}" title="{{ index . `title` | default (index . `alt`) }}" class="lazyload">
|
||||
{{- /* lazysizes and lightgallery.js */ -}}
|
||||
{{- $src := index . "src" -}}
|
||||
{{- $small := index . "src-s" | default $src -}}
|
||||
{{- $large := index . "src-l" | default $src -}}
|
||||
{{- $title := index . "title" -}}
|
||||
{{- $description := index . "description" -}}
|
||||
{{- $context := index . "context" -}}
|
||||
{{- $scratch := $context.Scratch.Get "scratch" -}}
|
||||
{{- $loading := resources.Get "svg/loading.svg" | minify -}}
|
||||
{{- if not (index . "src") | and (index . "src-s") -}}
|
||||
{{- $loading = resources.Get "svg/loading.small.svg" | minify -}}
|
||||
{{- end -}}
|
||||
{{- if index . "lightgallery" -}}
|
||||
<a class="lightgallery" href="{{ $large | safeURL }}" title="{{ $description }}" data-thumbnail="{{ $small | safeURL }}"{{ if $title }} data-sub-html="<h2>{{ $title }}</h2><p>{{ $description }}</p>"{{ end }}>
|
||||
<img
|
||||
class="lazyload"
|
||||
loading="lazy"
|
||||
src="{{ $loading.RelPermalink | safeURL }}"
|
||||
data-sizes="auto"
|
||||
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
|
||||
data-src="{{ $src | safeURL }}"
|
||||
alt="{{ $title | default $description }}" />
|
||||
</a>
|
||||
{{- $scratch.Set "lightgallery" true -}}
|
||||
{{- else -}}
|
||||
<img
|
||||
class="lazyload"
|
||||
loading="lazy"
|
||||
src="{{ $loading.RelPermalink | safeURL }}"
|
||||
data-sizes="auto"
|
||||
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
|
||||
data-src="{{ $src | safeURL }}"
|
||||
alt="{{ $title | default $description }}"
|
||||
title="{{ $description }}" />
|
||||
{{- end -}}
|
||||
{{- $scratch.Set "lazysizes" true -}}
|
||||
|
||||
Reference in New Issue
Block a user