redstrate.com/themes/red/layouts/partials/render-art.html

74 lines
2.6 KiB
HTML
Raw Normal View History

2023-04-13 11:45:52 -04:00
{{ $base := "art" }}
2023-04-13 17:19:53 -04:00
2023-04-13 11:45:52 -04:00
{{ if .Params.threed }}
2023-04-13 17:19:53 -04:00
{{ $base = "3d" }}
2023-04-13 11:45:52 -04:00
{{ end }}
{{ if .Params.animation }}
2023-04-13 17:19:53 -04:00
{{ $base = "animation" }}
{{ end }}
{{ $month := 1 }}
{{ $year := 1 }}
2022-12-28 10:24:59 -05:00
{{ if .Params.date }}
{{ $split := split .Params.date "-" }}
{{ $year = int (index $split 0) }}
{{ $month = int (index $split 3) }}
{{ end }}
2022-12-28 10:24:59 -05:00
{{ $use_newformat := false }}
{{ if ge (int $year) 2023 }}
{{ $use_newformat = true }}
{{ end }}
2024-02-19 14:39:10 -05:00
{{ if in .File.Dir "art/guest" }}
{{ $use_newformat = false }}
{{ end }}
2022-12-28 10:24:59 -05:00
{{ $full := "" }}
{{ $jpeg := "" }}
{{ if and $use_newformat (eq $base "art") }}
{{ $full = printf "https://images.redstrate.com/thumb/%s.avif" .Params.slug }}
{{ $jpeg = printf "https://images.redstrate.com/thumb/%s.jpg" .Params.slug }}
{{ else }}
{{ $full = resources.Get (printf "%s/%s.webp" $base .Params.slug) }}
{{ end }}
{{ if $full }}
{{ $filename_without_ext := .Params.slug }}
2023-04-13 11:45:52 -04:00
<a aria-label="Gallery Item" class="no-decoration grid-item" href="{{ .RelPermalink }}">
2023-02-10 14:25:28 -05:00
{{ $title := .Params.title }}
2023-02-10 14:25:28 -05:00
{{ with $full }}
{{ if $.Params.threed }}
{{ with resources.Get "3d.png" }}
2024-02-19 17:54:20 -05:00
<img alt="3D cube icon" title="Viewable 3D" style="z-index: 1; position: absolute; left: 10px; top: 10px; border: none" src="{{ .RelPermalink }}">
{{ end }}
{{ end }}
{{ if $.Params.animation }}
{{ with resources.Get "play-circle.png" }}
2024-02-19 17:54:20 -05:00
<img alt="Play animation icon" title="Viewable Animation" style="z-index: 1; position: absolute; left: 10px; top: 10px; border: none" src="{{ .RelPermalink }}">
{{ end }}
{{ end }}
2023-04-13 18:38:37 -04:00
{{ if and $use_newformat (eq $base "art") }}
<picture>
<source srcset="{{ $full }}" type="image/avif"/>
2024-02-19 17:54:20 -05:00
<img style="width: 100%; height: auto;" alt="{{ $.Params.alt_text }}" title="{{ $title }}" src="{{ $jpeg }}"/>
</picture>
2023-04-13 17:19:53 -04:00
{{ else }}
2024-02-19 17:54:20 -05:00
<img style="width: 100%; height: auto;" width="{{ .Width }}" height="{{ .Height }}" alt="{{ $.Params.alt_text }}" title="{{ $title }}" src="{{ .RelPermalink }}">
{{ end }}
{{ else }}
<p>Thumbnail not found!</p>
{{ end }}
2023-04-13 17:19:53 -04:00
</a>
2022-12-28 10:24:59 -05:00
{{ else }}
<em>CANNOT FIND {{ .Params.slug }} {{ $use_newformat }}</em>
2022-12-28 10:24:59 -05:00
{{ end }}
2023-04-13 11:45:52 -04:00