update
This commit is contained in:
24
layouts/_default/_markup/render-image.html
Normal file
24
layouts/_default/_markup/render-image.html
Normal file
@@ -0,0 +1,24 @@
|
||||
{{ $src := .Destination }}
|
||||
{{ $alt := .Text | default "image" }}
|
||||
{{ $title := .Title }}
|
||||
{{ $isRemote := strings.HasPrefix $src "http" }}
|
||||
|
||||
{{ if $isRemote }}
|
||||
{{ with resources.GetRemote $src }}
|
||||
{{ if eq .MediaType.SubType "svg" }}
|
||||
<img src="{{ $src }}" alt="{{ $alt }}" {{ if $title }}title="{{ $title }}"{{ end }} loading="lazy">
|
||||
{{ else }}
|
||||
{{ $webp := .Resize "800x webp" | fingerprint }}
|
||||
<img src="{{ $webp.RelPermalink }}" alt="{{ $alt }}" {{ if $title }}title="{{ $title }}"{{ end }} loading="lazy">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ else }}
|
||||
{{ with resources.Get $src }}
|
||||
{{ if eq .MediaType.SubType "svg" }}
|
||||
<img src="{{ $src }}" alt="{{ $alt }}" {{ if $title }}title="{{ $title }}"{{ end }} loading="lazy">
|
||||
{{ else }}
|
||||
{{ $resized := .Resize "800x webp" }}
|
||||
<img src="{{ $resized.RelPermalink }}" alt="{{ $alt }}" {{ if $title }}title="{{ $title }}"{{ end }} loading="lazy">
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
{{ end }}
|
||||
Reference in New Issue
Block a user