Browse Source

shrink images for more screen sizes

master
Alexander Avery 1 year ago
parent
commit
6f018fa3dd
  1. 22
      layouts/partials/responsive-image.html
  2. 6
      layouts/shortcodes/responsive-image.html

22
layouts/partials/responsive-image.html

@ -2,13 +2,10 @@
<img class="{{ .class | default "fill-wh"}}" <img class="{{ .class | default "fill-wh"}}"
{{ with resources.Get .context.Params.featured.url }} {{ with resources.Get .context.Params.featured.url }}
srcset=" srcset="
{{ (.Resize "420x q50").RelPermalink }} 420w, {{ (.Resize "320x q30").RelPermalink }} 500w,
{{ (.Resize "700x q65").RelPermalink }} 700w, {{ (.Resize "600x q40").RelPermalink }} 800w,
{{ (.Resize "1200x q65").RelPermalink }} 1200w" {{ (.Resize "1200x q65").RelPermalink }} 2x"
sizes="(max-width: 400px) 420px, src="{{ (.Resize "320x q30").RelPermalink }}"
(max-width: 1000px) 700px,
1200px"
src="{{ .RelPermalink }}"
{{ end }} {{ end }}
alt="{{ .context.Params.featured.alt }}" alt="{{ .context.Params.featured.alt }}"
/> />
@ -16,13 +13,10 @@
<img class="{{ .class | default "fill-wh"}}" <img class="{{ .class | default "fill-wh"}}"
{{ with .context.Resources.GetMatch .context.Params.featured.url }} {{ with .context.Resources.GetMatch .context.Params.featured.url }}
srcset=" srcset="
{{ (.Resize "420x q50").RelPermalink }} 420w, {{ (.Resize "320x q30").RelPermalink }} 500w,
{{ (.Resize "700x q65").RelPermalink }} 700w, {{ (.Resize "600x q40").RelPermalink }} 800w,
{{ (.Resize "1200x q65").RelPermalink }} 1200w" {{ (.Resize "1200x q65").RelPermalink }} 2x"
sizes="(max-width: 400px) 420px, src="{{ (.Resize "320x q30").RelPermalink }}"
(max-width: 1000px) 700px,
1200px"
src="{{ .RelPermalink }}"
alt="{{ .Params.alt }}" alt="{{ .Params.alt }}"
{{ end }} {{ end }}
/> />

6
layouts/shortcodes/responsive-image.html

@ -1,10 +1,10 @@
<img class="{{ .Get "class" | default "fill-wh" }}" <img class="{{ .Get "class" | default "fill-wh" }}"
{{ with .Get "src" | .Page.Resources.GetMatch }} {{ with .Get "src" | .Page.Resources.GetMatch }}
srcset=" srcset="
{{ (.Resize "320x q30").RelPermalink }} 320w, {{ (.Resize "320x q30").RelPermalink }} 500w,
{{ (.Resize "600x q40").RelPermalink }} 600w, {{ (.Resize "600x q40").RelPermalink }} 800w,
{{ (.Resize "1200x q65").RelPermalink }} 2x" {{ (.Resize "1200x q65").RelPermalink }} 2x"
src="{{ .RelPermalink }}" src="{{ (.Resize "320x q30").RelPermalink }}"
{{ end }} {{ end }}
alt="{{ .Get "alt" }}" alt="{{ .Get "alt" }}"
/> />

Loading…
Cancel
Save