update image resolution
This commit is contained in:
parent
0f0a7547cc
commit
83facd78ec
@ -9,7 +9,7 @@ care about is 700*4=2800px.
|
|||||||
|
|
||||||
<!-- image -->
|
<!-- image -->
|
||||||
{{ $src := resources.GetMatch (.Get "src") | resources.Fingerprint }}
|
{{ $src := resources.GetMatch (.Get "src") | resources.Fingerprint }}
|
||||||
{{ $max := $src | resources.Fingerprint }}
|
{{ $jmax := $src | resources.Fingerprint }}
|
||||||
{{ $j350 := $src.Resize "350x" }}
|
{{ $j350 := $src.Resize "350x" }}
|
||||||
{{ $j700 := $src.Resize "700x" }}
|
{{ $j700 := $src.Resize "700x" }}
|
||||||
{{ $j1400 := $src.Resize "1400x" }}
|
{{ $j1400 := $src.Resize "1400x" }}
|
||||||
@ -22,6 +22,7 @@ care about is 700*4=2800px.
|
|||||||
{{ errorf "missing value for param 'hint': %s" .Position }}
|
{{ errorf "missing value for param 'hint': %s" .Position }}
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ $hint := .Get "hint" }}
|
{{ $hint := .Get "hint" }}
|
||||||
|
{{ $wmax := $src.Resize (printf "%dx%d webp" $src.Width $src.Height) }}
|
||||||
{{ $w350 := $src.Resize (print "350x webp " $hint ) }}
|
{{ $w350 := $src.Resize (print "350x webp " $hint ) }}
|
||||||
{{ $w700 := $src.Resize (print "700x webp " $hint ) }}
|
{{ $w700 := $src.Resize (print "700x webp " $hint ) }}
|
||||||
{{ $w1400 := $src.Resize (print "1400x webp " $hint ) }}
|
{{ $w1400 := $src.Resize (print "1400x webp " $hint ) }}
|
||||||
@ -31,36 +32,44 @@ care about is 700*4=2800px.
|
|||||||
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
|
{{ with .Get "link" }}<a href="{{ . }}">{{ end }}
|
||||||
<picture>
|
<picture>
|
||||||
<source type="image/webp"
|
<source type="image/webp"
|
||||||
sizes="(max-width: 600px) 350px, {{ $width }}"
|
sizes="(max-width: 600px) 350px, {{ $width }}"
|
||||||
srcset='
|
{{- if eq $hint "graph" }}
|
||||||
{{- if ge $src.Width "350" }}
|
srcset='{{ $wmax.RelPermalink}} {{ $wmax.Width}}w'
|
||||||
{{ with $w350.RelPermalink }}{{.}} 350w{{ end }}
|
{{- else }}
|
||||||
|
srcset='
|
||||||
|
{{- if ge $src.Width "350" }}
|
||||||
|
{{ with $w350.RelPermalink }}{{.}} 350w{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if ge $src.Width "700" }}
|
||||||
|
{{ with $w700.RelPermalink }}, {{.}} 700w{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if ge $src.Width "1400" }}
|
||||||
|
{{ with $w1400.RelPermalink }}, {{.}} 1400w{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if ge $src.Width "2800" }}
|
||||||
|
{{ with $w2800.RelPermalink }}, {{.}} 2800w{{ end }}
|
||||||
|
{{- end }}'
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if ge $src.Width "700" }}
|
|
||||||
{{ with $w700.RelPermalink }}, {{.}} 700w{{ end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if ge $src.Width "1400" }}
|
|
||||||
{{ with $w1400.RelPermalink }}, {{.}} 1400w{{ end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if ge $src.Width "2800" }}
|
|
||||||
{{ with $w2800.RelPermalink }}, {{.}} 2800w{{ end }}
|
|
||||||
{{- end }}'
|
|
||||||
/>
|
/>
|
||||||
<img
|
<img
|
||||||
sizes="(max-width: 600px) 350px, 700px"
|
sizes="(max-width: 600px) 350px, 700px"
|
||||||
srcset='
|
{{- if eq $hint "graph" }}
|
||||||
{{- if ge $src.Width "350" }}
|
srcset='{{ $jmax.RelPermalink}} {{ $jmax.Width}}w'
|
||||||
{{ with $j350.RelPermalink }}{{.}} 350w{{ end }}
|
{{- else }}
|
||||||
|
srcset='
|
||||||
|
{{- if ge $src.Width "350" }}
|
||||||
|
{{ with $j350.RelPermalink }}{{.}} 350w{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if ge $src.Width "700" }}
|
||||||
|
{{ with $j700.RelPermalink }}, {{.}} 700w{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if ge $src.Width "1400" }}
|
||||||
|
{{ with $j1400.RelPermalink }}, {{.}} 1400w{{ end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- if ge $src.Width "2800" }}
|
||||||
|
{{ with $j2800.RelPermalink }}, {{.}} 2800w{{ end }}
|
||||||
|
{{- end }}'
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- if ge $src.Width "700" }}
|
|
||||||
{{ with $j700.RelPermalink }}, {{.}} 700w{{ end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if ge $src.Width "1400" }}
|
|
||||||
{{ with $j1400.RelPermalink }}, {{.}} 1400w{{ end }}
|
|
||||||
{{- end }}
|
|
||||||
{{- if ge $src.Width "2800" }}
|
|
||||||
{{ with $j2800.RelPermalink }}, {{.}} 2800w{{ end }}
|
|
||||||
{{- end }}'
|
|
||||||
src="{{ $j700.RelPermalink }}"
|
src="{{ $j700.RelPermalink }}"
|
||||||
{{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }}
|
{{ if or (.Get "alt") (.Get "caption") }}alt="{{ with .Get "alt" }}{{ . }}{{ else }}{{ .Get "caption" }}{{ end }}"{{ end }}
|
||||||
/>
|
/>
|
||||||
|
Loading…
Reference in New Issue
Block a user