Improve image and smallimg support of webp

This commit is contained in:
Joe Hutchinson
2019-01-21 11:24:09 -05:00
parent 59b3abd760
commit 80344a5c6c
2 changed files with 21 additions and 13 deletions

View File

@@ -1,5 +1,7 @@
<picture>
<source srcset="{{ replace (index .Params "src") (path.Ext (index .Params "src")) ".webp" | absURL }}" type="image/webp">
<source srcset="{{ index .Params "src" | absURL }}">
{{ if (fileExists (printf "%s/%s" "static" (replace (index .Params "src") (path.Ext (index .Params "src")) ".webp"))) -}}
<source srcset="{{ replace (index .Params "src") (path.Ext (index .Params "src")) ".webp" | absURL }}" type="image/webp">
{{- end }}
<source srcset="{{ index .Params "src" | absURL }}">
<img src="{{ index .Params "src" | absURL }}" {{ if isset .Params "alt" -}} alt="{{ index .Params "alt"}}" {{- end }}>
</picture>