This commit is contained in:
parent
4b35583782
commit
e77051ccc4
1987 changed files with 1147290 additions and 5648 deletions
55
themes/blowfish/layouts/shortcodes/figure.html
Normal file
55
themes/blowfish/layouts/shortcodes/figure.html
Normal file
|
@ -0,0 +1,55 @@
|
|||
{{ $disableImageOptimization := .Site.Params.disableImageOptimization | default false }}
|
||||
{{ if .Get "default" }}
|
||||
{{ template "_internal/shortcodes/figure.html" . }}
|
||||
{{ else }}
|
||||
{{ $url := urls.Parse (.Get "src") }}
|
||||
{{ $altText := .Get "alt" }}
|
||||
{{ $caption := .Get "caption" }}
|
||||
{{ $href := .Get "href" }}
|
||||
{{ $class := .Get "class" }}
|
||||
{{ $target := .Get "target" }}
|
||||
{{ $nozoom := .Get "nozoom" | default false }}
|
||||
{{ if findRE "^https?" $url.Scheme }}
|
||||
<figure>
|
||||
<img class="my-0 rounded-md" src="{{ $url.String }}" alt="{{ $altText }}" />
|
||||
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ else }}
|
||||
{{ $resource := "" }}
|
||||
{{ if $.Page.Resources.GetMatch ($url.String) }}
|
||||
{{ $resource = $.Page.Resources.GetMatch ($url.String) }}
|
||||
{{ else if resources.GetMatch ($url.String) }}
|
||||
{{ $resource = resources.Get ($url.String) }}
|
||||
{{ end }}
|
||||
{{ with $resource }}
|
||||
<figure {{ with $class }}class="{{ . }}"{{ end }}>
|
||||
{{ with $href }}<a href="{{ . }}" {{ with $target }}target="{{ . }}"{{ end }}>{{ end }}
|
||||
{{ if $disableImageOptimization }}
|
||||
<img
|
||||
class="my-0 rounded-md{{ if $nozoom }} nozoom{{ end }}"
|
||||
src="{{ .RelPermalink }}"
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{ else }}
|
||||
<img
|
||||
class="my-0 rounded-md{{ if $nozoom }} nozoom{{ end }}"
|
||||
srcset="
|
||||
{{ (.Resize "330x").RelPermalink }} 330w,
|
||||
{{ (.Resize "660x").RelPermalink }} 660w,
|
||||
{{ (.Resize "1024x").RelPermalink }} 1024w,
|
||||
{{ (.Resize "1320x").RelPermalink }} 2x"
|
||||
src="{{ (.Resize "660x").RelPermalink }}"
|
||||
alt="{{ $altText }}"
|
||||
/>
|
||||
{{ end }}
|
||||
{{ if $href }}</a>{{ end }}
|
||||
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ else }}
|
||||
<figure>
|
||||
<img class="my-0 rounded-md{{ if $nozoom }} nozoom{{ end }}" src="{{ $url.String }}" alt="{{ $altText }}" />
|
||||
{{ with $caption }}<figcaption>{{ . | markdownify }}</figcaption>{{ end }}
|
||||
</figure>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
Loading…
Add table
Add a link
Reference in a new issue