Page MenuHomePhorge

No OneTemporary

diff --git a/layouts/shortcodes/figurec.html b/layouts/shortcodes/figurec.html
new file mode 100644
index 0000000..ef4ea8d
--- /dev/null
+++ b/layouts/shortcodes/figurec.html
@@ -0,0 +1,26 @@
+{{ $srcset := "360|(max-width: 37.5em) 360px,720|(min-width: 75em) 720px,1920|(min-width: 112.5em) 1200px" }}
+{{ $srcset := split $srcset "," }}
+{{ $original := (.Page.Resources.ByType "image").GetMatch (printf "*%s" (.Get "src")) }}
+<!-- image -->
+{{ if $original }}
+<figure{{ with .Get "class" }} class="{{.}}"{{ end }}>
+ <!-- image without srcset -->
+ {{ if .Get "link"}}<a href="{{ .Get "link" }}"{{ with .Get "target" }} target="{{ . }}"{{ end }}{{ with .Get "rel" }} rel="{{ . }}"{{ end }}>{{ end }}
+ <img src="{{ $original.RelPermalink }}" srcset="{{range $i, $set := $srcset}}{{ $setparams := split $set "|" }}{{$sizecondition := index $setparams 0 }}{{ $image := $original.Resize (print $sizecondition "x webp q90") }}{{ if $i }}, {{ end }}{{ (print $image.RelPermalink " " $sizecondition "w") }}{{ end }}" sizes="{{range $i, $set := $srcset}}{{ $setparams := split $set "|" }}{{$mediacondition := index $setparams 1 }}{{ if $i }}, {{ end }}{{ $mediacondition }}{{ end }}" {{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt"}}{{.}}{{else}}{{ .Get "caption" }}{{ end }}" {{ end }}{{ with .Get "width" }}width="{{.}}" {{ end }}{{ with .Get "height" }}height="{{.}}" {{ end }}/>
+ {{ if .Get "link"}}</a>{{ end }}
+ {{ if or (or (.Get "title") (.Get "caption")) (.Get "attr")}}
+ <figcaption>{{ if isset .Params "title" }}
+ <h4>{{ .Get "title" }}</h4>{{ end }}
+ {{ if or (.Get "caption") (.Get "attr")}}<p>
+ {{ .Get "caption" }}
+ {{ with .Get "attrlink"}}<a href="{{.}}"> {{ end }}
+ {{ .Get "attr" }}
+ {{ if .Get "attrlink"}}</a> {{ end }}
+ </p> {{ end }}
+ </figcaption>
+ {{ end }}
+</figure>
+{{ else }}
+ [{{ .Get "src"}} not found]
+{{ end }}
+<!-- image -->
\ No newline at end of file

File Metadata

Mime Type
text/x-diff
Expires
Tue, Jul 8, 06:41 (1 d, 9 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28300
Default Alt Text
(1 KB)

Event Timeline