diff options
author | asurbernardo <asur@asurbernardo.com> | 2020-07-18 16:52:11 +0300 |
---|---|---|
committer | asurbernardo <asur@asurbernardo.com> | 2020-07-18 16:52:11 +0300 |
commit | 2a17c5b763b4560a8e0c439b20ae8a7e709271d5 (patch) | |
tree | 2d8e057faed3452b46ed9cbc2f44c01fa810675c | |
parent | b77b43620fa4fa6135e253b9a38565cdd35d7442 (diff) |
Improve image srcset detection
-rw-r--r-- | layouts/partials/blocks/image.html | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/layouts/partials/blocks/image.html b/layouts/partials/blocks/image.html index 346a817..2edccf3 100644 --- a/layouts/partials/blocks/image.html +++ b/layouts/partials/blocks/image.html @@ -1,5 +1,4 @@ <figure class="figure {{ with .caption }}figure--with-caption{{ end }}"> - {{ with .caption }} <figcaption class="figure__caption"> {{ . }} @@ -7,11 +6,11 @@ {{ end }} {{ $resource := resources.Get .src }} {{ with $resource }} - {{ if eq .MediaType "image/jpeg"}} + {{ if in (slice "jpeg" "jpg" "png" "gif") $resource.MediaType.SubType }} <amp-img src="{{ .Permalink | absURL }}" srcset="{{ (.Resize "1200x").Permalink }} 1200w, - {{ (.Resize "800x").Permalink }} 800w, + {{ (.Resize "900x").Permalink }} 900w, {{ (.Resize "640x").Permalink }} 640w, {{ (.Resize "480x").Permalink }} 480w, {{ (.Resize "320x").Permalink }} 320w" @@ -22,6 +21,7 @@ class="figure__image {{ with $.class }}{{ . }}{{ end }} {{ with $.caption }}figure__image--with-caption{{ end }}"> </amp-img> {{ else }} + FOO <amp-img src="{{ .Permalink | absURL }}" width={{ with $.width }} "{{ . }}" {{ else }} {{ .Width }} {{ end }} |