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

6
layouts/shortcodes/responsive-image.html

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

Loading…
Cancel
Save