This commit is contained in:
Kirchik
2025-08-13 22:36:08 +02:00
parent 6d061248de
commit e23fc02f63
254 changed files with 9579 additions and 4378 deletions
+22 -5
View File
@@ -1,19 +1,36 @@
<!--
Put this file in /layouts/shortcodes/figure.html
Updated figure shortcode for S3 images
NB this overrides Hugo's built-in "figure" shortcode but is backwards compatible
Documentation and licence at https://github.com/liwenyip/hugo-easy-gallery/
-->
<!-- count how many times we've called this shortcode; load the css if it's the first time -->
{{- if not ($.Page.Scratch.Get "figurecount") }}<link rel="stylesheet" href="{{ "css/hugo-easy-gallery.css" | relURL }}?v={{ now.Unix }}&update=2" />{{ end }}
{{- $.Page.Scratch.Add "figurecount" 1 -}}
<!-- use either src or link-thumb for thumbnail image -->
{{- $thumb := .Get "src" | default (printf "%s." (.Get "thumb") | replace (.Get "link") ".") }}
<!-- Check if image URL is already absolute (starts with http/https) -->
{{- $thumbURL := "" }}
{{- if or (hasPrefix $thumb "http://") (hasPrefix $thumb "https://") }}
{{- $thumbURL = $thumb }}
{{- else }}
{{- $thumbURL = $thumb | relURL }}
{{- end }}
{{- $linkURL := "" }}
{{- $link := .Get "link" | default (.Get "src") }}
{{- if or (hasPrefix $link "http://") (hasPrefix $link "https://") }}
{{- $linkURL = $link }}
{{- else }}
{{- $linkURL = $link | relURL }}
{{- end }}
<div class="box{{ with .Get "caption-position" }} fancy-figure caption-position-{{.}}{{end}}{{ with .Get "caption-effect" }} caption-effect-{{.}}{{end}}" {{ with .Get "width" }}style="max-width:{{.}}"{{end}}>
<figure {{ with .Get "class" }}class="{{.}}"{{ end }} itemprop="associatedMedia" itemscope itemtype="http://schema.org/ImageObject">
<div class="img"{{ if .Parent }} style="background-image: url('{{ $thumb | relURL }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}>
<img itemprop="thumbnail" src="{{ $thumb | relURL }}" {{ with .Get "alt" | default (.Get "caption") }}alt="{{.}}"{{ end }}/><!-- <img> hidden if in .gallery -->
<div class="img"{{ if .Parent }} style="background-image: url('{{ $thumbURL }}');"{{ end }}{{ with .Get "size" }} data-size="{{.}}"{{ end }}>
<img itemprop="thumbnail" src="{{ $thumbURL }}" {{ with .Get "alt" | default (.Get "caption") }}alt="{{.}}"{{ end }}/><!-- <img> hidden if in .gallery -->
</div>
{{ with .Get "link" | default (.Get "src") }}<a href="{{ . | relURL }}" itemprop="contentUrl"></a>{{ end }}
{{ with $linkURL }}<a href="{{ . }}" itemprop="contentUrl"></a>{{ end }}
{{- if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
<figcaption>
{{- with .Get "title" }}<h4>{{.}}</h4>{{ end }}