mirror of https://github.com/jpanther/congo.git
potential solution to screenshot
parent
06195bc379
commit
954fd7fac9
|
@ -10,9 +10,17 @@
|
||||||
{{ $img = resources.Get $path }}
|
{{ $img = resources.Get $path }}
|
||||||
{{ end -}}
|
{{ end -}}
|
||||||
|
|
||||||
|
{{/* https://github.com/gohugoio/hugo/pull/10666/files */}}
|
||||||
|
{{- $params := $url.Query -}}
|
||||||
|
{{- $x2Param := $params.Get "x2" -}}
|
||||||
|
{{- $x2 := false -}}
|
||||||
|
{{- if eq $x2Param "true" -}}
|
||||||
|
{{- $x2 = true -}}
|
||||||
|
{{- end -}}
|
||||||
|
|
||||||
<figure>
|
<figure>
|
||||||
{{- with $img -}}
|
{{- with $img -}}
|
||||||
{{ partial "pictureDefaults.html" (dict "img" . "alt" $altText "class" $class) }}
|
{{ partial "pictureDefaults.html" (dict "img" . "alt" $altText "class" $class "x2" $x2) }}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
<img src="{{ .Destination | safeURL }}" alt="{{ $altText }}" class="{{ $class }}"/>
|
<img src="{{ .Destination | safeURL }}" alt="{{ $altText }}" class="{{ $class }}"/>
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
{{ $lazy := .lazy }}
|
{{ $lazy := .lazy }}
|
||||||
{{ $webp := .webp }}
|
{{ $webp := .webp }}
|
||||||
{{ $lqip := .lqip }}
|
{{ $lqip := .lqip }}
|
||||||
|
{{ $x2 := .x2 | default false }}
|
||||||
|
|
||||||
{{ with $img }}
|
{{ with $img }}
|
||||||
{{ if (eq .MediaType.SubType "svg") }}
|
{{ if (eq .MediaType.SubType "svg") }}
|
||||||
|
@ -45,6 +46,12 @@
|
||||||
style="background-image:url(data:image/webp;base64,{{ $bg }});background-size:cover"
|
style="background-image:url(data:image/webp;base64,{{ $bg }});background-size:cover"
|
||||||
{{ end }}
|
{{ end }}
|
||||||
>
|
>
|
||||||
|
{{ $width := .Width }}
|
||||||
|
{{ $height := .Height }}
|
||||||
|
{{ if $x2 }}
|
||||||
|
{{ $width = div .Width 2 }}
|
||||||
|
{{ $height = div .Height 2 }}
|
||||||
|
{{ end }}
|
||||||
{{ if $webp }}
|
{{ if $webp }}
|
||||||
<source
|
<source
|
||||||
{{ if lt .Width 660 }}
|
{{ if lt .Width 660 }}
|
||||||
|
@ -76,8 +83,8 @@
|
||||||
{{ end }}
|
{{ end }}
|
||||||
<img
|
<img
|
||||||
src="{{ .RelPermalink }}"
|
src="{{ .RelPermalink }}"
|
||||||
width="{{ .Width }}"
|
width="{{ $width }}"
|
||||||
height="{{ .Height }}"
|
height="{{ $height }}"
|
||||||
{{ with $class }} class="{{ . }}" {{ end }}
|
{{ with $class }} class="{{ . }}" {{ end }}
|
||||||
{{ with $alt }} alt="{{ . }}" {{ end }}
|
{{ with $alt }} alt="{{ . }}" {{ end }}
|
||||||
{{ with $lazy }} loading="lazy" decoding="async" {{ end }}
|
{{ with $lazy }} loading="lazy" decoding="async" {{ end }}
|
||||||
|
|
|
@ -4,4 +4,5 @@
|
||||||
{{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
{{ $lazy := $.Page.Site.Params.enableImageLazyLoading | default true }}
|
||||||
{{ $webp := $.Page.Site.Params.enableImageWebp | default true }}
|
{{ $webp := $.Page.Site.Params.enableImageWebp | default true }}
|
||||||
{{ $lqip := false }}
|
{{ $lqip := false }}
|
||||||
{{ partial "picture.html" (dict "img" $img "alt" $alt "class" $class "lazy" $lazy "webp" $webp "lqip" $lqip) }}
|
{{ $x2 := .x2 }}
|
||||||
|
{{ partial "picture.html" (dict "img" $img "alt" $alt "class" $class "lazy" $lazy "webp" $webp "lqip" $lqip "x2" $x2) }}
|
|
@ -4,17 +4,16 @@
|
||||||
{{- if .Get "href" -}}
|
{{- if .Get "href" -}}
|
||||||
<a href="{{ .Get "href" }}">
|
<a href="{{ .Get "href" }}">
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
<img src="{{ $image.RelPermalink }}"
|
|
||||||
{{- if or (.Get "alt") (.Get "caption") }}
|
{{ $altText := "" }}
|
||||||
alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" | markdownify | plainify }}{{ end }}"
|
{{ with .Get "alt" }}
|
||||||
{{- end -}}
|
{{ $altText = . }}
|
||||||
{{ if .Site.Params.enableImageLazyLoading | default true }}
|
{{ else }}
|
||||||
loading="lazy"
|
{{ $altText = (.Get "caption") | markdownify | plainify }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
width="100%"
|
|
||||||
height="auto"
|
{{ partial "pictureDefaults.html" (dict "img" $image "alt" $altText "x2" true) }}
|
||||||
style="max-width:{{ div $image.Width 2 }}px; max-height:{{ div $image.Height 2 }}px;"
|
|
||||||
/>
|
|
||||||
{{- if .Get "href" }}</a>{{ end -}}
|
{{- if .Get "href" }}</a>{{ end -}}
|
||||||
{{- if .Get "caption" -}}
|
{{- if .Get "caption" -}}
|
||||||
<figcaption>
|
<figcaption>
|
||||||
|
|
Loading…
Reference in New Issue