Add image processing to missing components + Update examples
This commit is contained in:
parent
94138f89f0
commit
7317ba53de
26 changed files with 171 additions and 111 deletions
|
@ -4,50 +4,50 @@
|
|||
{{ $src := resources.GetMatch (.Get "src") }}
|
||||
|
||||
{{ if in (.Get "src") "http" }}
|
||||
<img src="{{$src}}" {{ with .Get "alt" }}alt="{{.}}"{{ else }}alt=""{{ end }}>
|
||||
<img src="{{$src}}" {{ with .Get "alt" }}alt="{{.}}"{{ else }}alt=""{{ end }}>
|
||||
{{ else }}
|
||||
{{ if in (.Get "src") ".gif" }}
|
||||
<img src="{{$src.RelPermalink}}" {{ with .Get "alt" }}alt="{{.}}"{{ else }}alt=""{{ end }}>
|
||||
{{ else }}
|
||||
{{/* set image sizes, these are hardcoded for now */}}
|
||||
{{ if in (.Get "src") ".gif" }}
|
||||
<img src="{{$src.RelPermalink}}" {{ with .Get "alt" }}alt="{{.}}"{{ else }}alt=""{{ end }}>
|
||||
{{ else }}
|
||||
{{/* set image sizes, these are hardcoded for now */}}
|
||||
|
||||
{{ $tinyw := default "500x" }}
|
||||
{{ $smallw := default "800x" }}
|
||||
{{ $mediumw := default "1200x" }}
|
||||
{{ $largew := default "1500x" }}
|
||||
{{ $tinyw := default "500x" }}
|
||||
{{ $smallw := default "800x" }}
|
||||
{{ $mediumw := default "1200x" }}
|
||||
{{ $largew := default "1500x" }}
|
||||
|
||||
{{/* resize the src image to the given sizes */}}
|
||||
{{/* resize the src image to the given sizes */}}
|
||||
|
||||
{{ $tiny := $src.Resize $tinyw }}
|
||||
{{ $small := $src.Resize $smallw }}
|
||||
{{ $medium := $src.Resize $mediumw }}
|
||||
{{ $large := $src.Resize $largew }}
|
||||
{{ $tiny := $src.Resize $tinyw }}
|
||||
{{ $small := $src.Resize $smallw }}
|
||||
{{ $medium := $src.Resize $mediumw }}
|
||||
{{ $large := $src.Resize $largew }}
|
||||
|
||||
{{/* add the processed images to the scratch */}}
|
||||
{{/* add the processed images to the scratch */}}
|
||||
|
||||
|
||||
{{/* only use images smaller than or equal to the src (original) image size */}}
|
||||
<img
|
||||
{{ with .Get "sizes" }}sizes='{{.}}'{{ else }}{{ end }}
|
||||
srcset='
|
||||
{{ if ge $src.Width "500" }}
|
||||
{{ with $tiny.RelPermalink }}{{.}} 500w{{ end }}
|
||||
{{ end }}
|
||||
{{ if ge $src.Width "800" }}
|
||||
{{ with $small.RelPermalink }}, {{.}} 800w{{ end }}
|
||||
{{ end }}
|
||||
{{ if ge $src.Width "1200" }}
|
||||
{{ with $medium.RelPermalink }}, {{.}} 1200w{{ end }}
|
||||
{{ end }}
|
||||
{{ if ge $src.Width "1500" }}
|
||||
{{ with $large.RelPermalink }}, {{.}} 1500w {{ end }}
|
||||
{{ end }}'
|
||||
{{ if .Get (print $medium) }}
|
||||
src="{{ $medium.RelPermalink }}"
|
||||
{{ else }}
|
||||
src="{{ $src.RelPermalink }}"
|
||||
{{ end }}
|
||||
|
||||
{{ with .Get "alt" }}alt='{{.}}'{{ end }}>
|
||||
{{/* only use images smaller than or equal to the src (original) image size */}}
|
||||
<img
|
||||
{{ with .Get "sizes" }}sizes='{{.}}'{{ else }}{{ end }}
|
||||
srcset='
|
||||
{{ if ge $src.Width "500" }}
|
||||
{{ with $tiny.RelPermalink }}{{.}} 500w{{ end }}
|
||||
{{ end }}
|
||||
{{ if ge $src.Width "800" }}
|
||||
{{ with $small.RelPermalink }}, {{.}} 800w{{ end }}
|
||||
{{ end }}
|
||||
{{ if ge $src.Width "1200" }}
|
||||
{{ with $medium.RelPermalink }}, {{.}} 1200w{{ end }}
|
||||
{{ end }}
|
||||
{{ if ge $src.Width "1500" }}
|
||||
{{ with $large.RelPermalink }}, {{.}} 1500w {{ end }}
|
||||
{{ end }}'
|
||||
{{ if .Get (print $medium) }}
|
||||
src="{{ $medium.RelPermalink }}"
|
||||
{{ else }}
|
||||
src="{{ $src.RelPermalink }}"
|
||||
{{ end }}
|
||||
|
||||
{{ with .Get "alt" }}alt='{{.}}'{{ end }}>
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
Loading…
Add table
Add a link
Reference in a new issue