diff options
author | amzrk2 | 2020-09-19 14:15:35 +0800 |
---|---|---|
committer | amzrk2 | 2020-09-19 14:15:35 +0800 |
commit | a43b353ca3e2d923ca8f0cdd1aeab70e5b1313a4 (patch) | |
tree | b084c409a1ec2facb7230727bc0dd4e64e7df995 /layouts/shortcodes | |
parent | 93722cd7f5fb51408a36c941c2188a373d01209b (diff) | |
download | hugo-theme-fuji-a43b353ca3e2d923ca8f0cdd1aeab70e5b1313a4.tar.gz hugo-theme-fuji-a43b353ca3e2d923ca8f0cdd1aeab70e5b1313a4.tar.bz2 hugo-theme-fuji-a43b353ca3e2d923ca8f0cdd1aeab70e5b1313a4.zip |
new: lazyload image shortcodes
Diffstat (limited to 'layouts/shortcodes')
-rw-r--r-- | layouts/shortcodes/img-lazy.html | 27 | ||||
-rw-r--r-- | layouts/shortcodes/img-nz-lazy.html | 54 | ||||
-rw-r--r-- | layouts/shortcodes/img-nz.html | 10 |
3 files changed, 14 insertions, 77 deletions
diff --git a/layouts/shortcodes/img-lazy.html b/layouts/shortcodes/img-lazy.html index bac255b..eed9b0e 100644 --- a/layouts/shortcodes/img-lazy.html +++ b/layouts/shortcodes/img-lazy.html @@ -1,22 +1,5 @@ -{{ if len .Params | eq 2 }} -<img - class="lazyload img-zoomable" - src="{{ .Site.Params.lazyPlaceholder | relURL }}" - data-src="{{ index .Params 1 | relURL | safeURL }}" - alt="{{ index .Params 0 }}" -/> -{{ else if len .Params | eq 3 }}{{ if eq (index .Params 0) "row" }} -<img - class="lazyload img-zoomable" - src="{{ .Site.Params.lazyPlaceholderRow | relURL }}" - data-src="{{ index .Params 2 | relURL | safeURL }}" - alt="{{ index .Params 1 }}" -/> -{{ else if eq (index .Params 0) "col" }} -<img - class="lazyload img-zoomable" - src="{{ .Site.Params.lazyPlaceholderCol | relURL }}" - data-src="{{ index .Params 2 | relURL | safeURL }}" - alt="{{ index .Params 1 }}" -/> -{{ else }}{{ end }}{{ else }}{{ end }} +{{- if len .Params | eq 3 -}} +<p><div class="image-wrapper ratio-{{ index .Params 0 }}"> + <img class="lazyload img-zoomable" data-src="{{ index .Params 2 | relURL | safeURL }}" alt="{{ index .Params 1 }}" /> +</div></p> +{{- end -}}
\ No newline at end of file diff --git a/layouts/shortcodes/img-nz-lazy.html b/layouts/shortcodes/img-nz-lazy.html index 8a46329..bba88b6 100644 --- a/layouts/shortcodes/img-nz-lazy.html +++ b/layouts/shortcodes/img-nz-lazy.html @@ -1,49 +1,5 @@ -{{ if len .Params | eq 2 }} -<img - class="lazyload" - src="{{ .Site.Params.lazyPlaceholder | relURL }}" - data-src="{{ index .Params 1 | relURL | safeURL }}" - alt="{{ index .Params 0 }}" -/> -{{ else if len .Params | eq 3 }}{{ if eq (index .Params 0) "row" }} -<img - class="lazyload" - src="{{ .Site.Params.lazyPlaceholderRow | relURL }}" - data-src="{{ index .Params 2 | relURL | safeURL }}" - alt="{{ index .Params 1 }}" -/> -{{ else if eq (index .Params 0) "col" }} -<img - class="lazyload" - src="{{ .Site.Params.lazyPlaceholderCol | relURL }}" - data-src="{{ index .Params 2 | relURL | safeURL }}" - alt="{{ index .Params 1 }}" -/> -{{ else }} -<a href="{{ index .Params 2 }}" target="_blank"> - <img - class="lazyload" - src="{{ .Site.Params.lazyPlaceholder | relURL }}" - data-src="{{ index .Params 1 | relURL | safeURL }}" - alt="{{ index .Params 0 }}" - /> -</a> -{{ end }}{{ else if len .Params | eq 4 }}{{ if eq (index .Params 0) "row" }} -<a href="{{ index .Params 3 }}" target="_blank"> - <img - class="lazyload" - src="{{ .Site.Params.lazyPlaceholderRow | relURL }}" - data-src="{{ index .Params 2 | relURL | safeURL }}" - alt="{{ index .Params 1 }}" - /> -</a> -{{ else if eq (index .Params 0) "col" }} -<a href="{{ index .Params 3 }}" target="_blank"> - <img - class="lazyload" - src="{{ .Site.Params.lazyPlaceholderCol | relURL }}" - data-src="{{ index .Params 2 | relURL | safeURL }}" - alt="{{ index .Params 1 }}" - /> -</a> -{{ else }}{{ end }}{{ else }}{{ end }} +{{- if len .Params | eq 3 -}} +<p><div class="image-wrapper ratio-{{ index .Params 0 }}"> + <img class="lazyload" data-src="{{ index .Params 2 | relURL | safeURL }}" alt="{{ index .Params 1 }}" /> +</div></p> +{{- end -}}
\ No newline at end of file diff --git a/layouts/shortcodes/img-nz.html b/layouts/shortcodes/img-nz.html index 2e4b3af..175dc5b 100644 --- a/layouts/shortcodes/img-nz.html +++ b/layouts/shortcodes/img-nz.html @@ -1,7 +1,5 @@ -{{ if (index .Params 2) }} -<a href="{{ index .Params 2 }}" target="_blank"> +{{- if len .Params | eq 2 -}} +<p> <img src="{{ index .Params 1 | relURL | safeURL }}" alt="{{ index .Params 0 }}" /> -</a> -{{ else }} -<img src="{{ index .Params 1 | relURL | safeURL }}" alt="{{ index .Params 0 }}" /> -{{ end }} +</p> +{{- end -}}
\ No newline at end of file |