Update gallery page
Signed-off-by: Nikolaos Karaolidis <nick@karaolidis.com>
This commit is contained in:
@@ -1,59 +1,26 @@
|
||||
{{- $page := .page -}}
|
||||
{{- $image := .image -}}
|
||||
|
||||
{{- $src := $image -}}
|
||||
{{- $caption := "" -}}
|
||||
{{- $title := "" -}}
|
||||
{{- $alt := "" -}}
|
||||
|
||||
{{- if reflect.IsMap $image -}}
|
||||
{{- $src = $image.src | default "" -}}
|
||||
{{- $caption = $image.caption | default "" -}}
|
||||
{{- $title = $image.title | default $caption | default "" | plainify -}}
|
||||
{{- $alt = $image.alt | default $title | default "" | plainify -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- if $src -}}
|
||||
{{- $isRemote := strings.HasPrefix $src "http" -}}
|
||||
|
||||
{{- if $isRemote -}}
|
||||
{{- $remote := resources.GetRemote $src -}}
|
||||
{{- $image = resources.Copy (printf "static/3rd-party/%s" $remote.Name) $remote -}}
|
||||
{{- else -}}
|
||||
{{- $image = ($page.Resources.Get $src) | default (resources.Get $src) -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- with $image -}}
|
||||
{{ $full := . | images.Filter (images.Process "webp q90") }}
|
||||
|
||||
{{ $thumb := . }}
|
||||
{{- if gt .Width 2000 -}}
|
||||
{{- $thumb = . | images.Filter (images.Process "resize 2000x webp q75") -}}
|
||||
{{- else -}}
|
||||
{{- $thumb = . | images.Filter (images.Process "webp q75") -}}
|
||||
{{- end -}}
|
||||
{{- $caption := .caption | default "" -}}
|
||||
{{- $title := .title | default $caption | plainify -}}
|
||||
{{- $alt := .alt | default $title | plainify -}}
|
||||
|
||||
|
||||
<figure class="captioned-image lightbox">
|
||||
<a
|
||||
href="{{- $full.RelPermalink -}}"
|
||||
data-pswp-src="{{- $full.RelPermalink -}}"
|
||||
data-pswp-width="{{- $full.Width -}}"
|
||||
data-pswp-height="{{- $full.Height -}}"
|
||||
class="pswp-image"
|
||||
>
|
||||
<img
|
||||
src="{{- $thumb.RelPermalink -}}"
|
||||
width="{{- $thumb.Width -}}"
|
||||
height="{{- $thumb.Height -}}"
|
||||
loading="lazy"
|
||||
{{ with $title }}title="{{- . -}}"{{ end }}
|
||||
{{ with $alt }}alt="{{- . -}}"{{ end }}
|
||||
/>
|
||||
</a>
|
||||
{{ with $caption }}
|
||||
<figcaption>{{ . | safeHTML }}</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
||||
{{- end -}}
|
||||
<figure class="captioned-image lightbox">
|
||||
<a
|
||||
href="{{- .full.RelPermalink -}}"
|
||||
data-pswp-src="{{- .full.RelPermalink -}}"
|
||||
data-pswp-width="{{- .full.Width -}}"
|
||||
data-pswp-height="{{- .full.Height -}}"
|
||||
class="pswp-image"
|
||||
>
|
||||
<img
|
||||
src="{{- .thumb.RelPermalink -}}"
|
||||
width="{{- .thumb.Width -}}"
|
||||
height="{{- .thumb.Height -}}"
|
||||
loading="lazy"
|
||||
{{ with $title }}title="{{- . -}}"{{ end }}
|
||||
{{ with $alt }}alt="{{- . -}}"{{ end }}
|
||||
/>
|
||||
</a>
|
||||
{{ with $caption }}
|
||||
<figcaption>{{ . | safeHTML }}</figcaption>
|
||||
{{ end }}
|
||||
</figure>
|
||||
|
23
layouts/partials/components/image/process.html
Normal file
23
layouts/partials/components/image/process.html
Normal file
@@ -0,0 +1,23 @@
|
||||
{{- $page := .page -}}
|
||||
{{- $src := .src -}}
|
||||
|
||||
{{- $original := "" -}}
|
||||
|
||||
{{- $isRemote := strings.HasPrefix $src "http" -}}
|
||||
{{- if $isRemote -}}
|
||||
{{- $remote := resources.GetRemote $src -}}
|
||||
{{- $original = resources.Copy (printf "static/3rd-party/%s" $remote.Name) $remote -}}
|
||||
{{- else -}}
|
||||
{{- $original = ($page.Resources.Get $src) | default (resources.Get $src) -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- $full := $original | images.Filter (images.Process "webp q90") -}}
|
||||
|
||||
{{- $thumb := "" -}}
|
||||
{{- if gt $original.Width 2000 -}}
|
||||
{{- $thumb = $original | images.Filter (images.Process "resize 2000x webp q75") -}}
|
||||
{{- else -}}
|
||||
{{- $thumb = $original | images.Filter (images.Process "webp q75") -}}
|
||||
{{- end -}}
|
||||
|
||||
{{- return (dict "original" $original "full" $full "thumb" $thumb) -}}
|
Reference in New Issue
Block a user