Added files of the theme
This commit is contained in:
36
layouts/shortcodes/smallimg.html
Normal file
36
layouts/shortcodes/smallimg.html
Normal file
@@ -0,0 +1,36 @@
|
||||
<picture class="small-pic {{ if eq .Params.clear "true" -}} clear {{- end }}">
|
||||
{{ if (fileExists (printf "%s/%s" "content" (replace (.Get "src") (path.Ext (.Get "src")) ".webp"))) -}}
|
||||
<source srcset="{{ replace (.Get "src") (path.Ext (.Get "src")) ".webp" | absURL }}" type="image/webp">
|
||||
{{- end }}
|
||||
{{ $image := $.Page.Resources.GetMatch (.Get "src") }}
|
||||
{{ if or (gt $image.Width 800) (and (isset .Params "width") (gt $image.Width (.Get "width"))) -}}
|
||||
{{ $.Scratch.Set "imgwidth" "800" }}
|
||||
{{ if and (isset .Params "width") (lt (.Get "width") 800) -}}
|
||||
{{ $.Scratch.Set "imgwidth" (trim (.Get "width") "px") }}
|
||||
{{- end }}
|
||||
{{ $resized := $image.Resize (printf "%sx Lanczos" ($.Scratch.Get "imgwidth")) }}
|
||||
<source srcset="{{ $resized.Permalink }}">
|
||||
<img src="{{ $resized.Permalink }}" class="small-img {{ if isset .Params "smartfloat" -}}
|
||||
{{- if eq .Params.smartfloat "left" -}}
|
||||
smartfloat-left
|
||||
{{- else if eq .Params.smartfloat "right" -}}
|
||||
smartfloat-right
|
||||
{{- end -}}
|
||||
{{- end }}"
|
||||
{{- with .Get "alt" }} alt="{{ . }}" {{ end -}}
|
||||
{{- with .Get "width" }} style="width: {{ . }};" {{- end -}}
|
||||
/>
|
||||
{{ else }}
|
||||
<source srcset="{{ $image.Permalink }}">
|
||||
<img src="{{ $image.Permalink }}" class="small-img {{ if isset .Params "smartfloat" -}}
|
||||
{{- if eq .Params.smartfloat "left" -}}
|
||||
smartfloat-left
|
||||
{{- else if eq .Params.smartfloat "right" -}}
|
||||
smartfloat-right
|
||||
{{- end -}}
|
||||
{{- end }}"
|
||||
{{- with .Get "alt" }} alt="{{ . }}" {{ end -}}
|
||||
{{- with .Get "width" }} style="width: {{ . }};" {{- end -}}
|
||||
/>
|
||||
{{- end }}
|
||||
</picture>
|
||||
Reference in New Issue
Block a user