Improve image and smallimg support of webp
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
<picture>
|
<picture>
|
||||||
<source srcset="{{ replace (index .Params "src") (path.Ext (index .Params "src")) ".webp" | absURL }}" type="image/webp">
|
{{ if (fileExists (printf "%s/%s" "static" (replace (index .Params "src") (path.Ext (index .Params "src")) ".webp"))) -}}
|
||||||
<source srcset="{{ index .Params "src" | absURL }}">
|
<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 }}>
|
<img src="{{ index .Params "src" | absURL }}" {{ if isset .Params "alt" -}} alt="{{ index .Params "alt"}}" {{- end }}>
|
||||||
</picture>
|
</picture>
|
||||||
@@ -1,11 +1,17 @@
|
|||||||
<img src="{{ index .Params "src" }}"
|
<picture>
|
||||||
{{- if isset .Params "alt" }} alt="{{ index .Params "alt"}}" {{ end -}}
|
{{ if (fileExists (printf "%s/%s" "static" (replace (index .Params "src") (path.Ext (index .Params "src")) ".webp"))) -}}
|
||||||
class="small-img {{ if isset .Params "smartfloat" -}}
|
<source srcset="{{ replace (index .Params "src") (path.Ext (index .Params "src")) ".webp" | absURL }}" type="image/webp">
|
||||||
{{- if eq .Params.smartfloat "left" -}}
|
{{- end }}
|
||||||
smartfloat-left
|
<source srcset="{{ index .Params "src" | absURL }}">
|
||||||
{{- else if eq .Params.smartfloat "right" -}}
|
<img src="{{ index .Params "src" | absURL }}"
|
||||||
smartfloat-right
|
{{- if isset .Params "alt" }} alt="{{ index .Params "alt"}}" {{ end -}}
|
||||||
{{- end -}}
|
class="small-img {{ if isset .Params "smartfloat" -}}
|
||||||
{{- end }}"
|
{{- if eq .Params.smartfloat "left" -}}
|
||||||
{{- if isset .Params "width" }} style="width: {{ index .Params "width" }};" {{- end -}}
|
smartfloat-left
|
||||||
/>
|
{{- else if eq .Params.smartfloat "right" -}}
|
||||||
|
smartfloat-right
|
||||||
|
{{- end -}}
|
||||||
|
{{- end }}"
|
||||||
|
{{- if isset .Params "width" }} style="width: {{ index .Params "width" }};" {{- end -}}
|
||||||
|
/>
|
||||||
|
</picture>
|
||||||
Reference in New Issue
Block a user