Skip to content

Commit

Permalink
fix: missing height and weight of img element and lazyload object-fit…
Browse files Browse the repository at this point in the history
… style
  • Loading branch information
dillonzq committed May 12, 2022
1 parent 568fe8f commit 428d8b8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 10 deletions.
9 changes: 7 additions & 2 deletions assets/css/_page/_single.scss
Original file line number Diff line number Diff line change
Expand Up @@ -230,14 +230,19 @@

img {
display: block;
width: 100%;
height: auto;
margin: 0 auto;
overflow: hidden;
}
}

.lazyloading {
@include object-fit(none);
.lazyload, .lazyloading {
@include object-fit(scale-down);
}

.lazyloaded {
@include object-fit(fill);
}

blockquote {
Expand Down
22 changes: 15 additions & 7 deletions layouts/partials/plugin/image.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
{{- /* lazysizes and lightgallery */ -}}
{{- $src := .Src -}}
{{- with dict "Path" .Src "Resources" .Resources | partial "function/resource.html" -}}
{{- $width := .Width -}}
{{- $height := .Height -}}
{{- with dict "Path" $src "Resources" .Resources | partial "function/resource.html" -}}
{{- $src = .RelPermalink -}}
{{- $width = $width | default .Width -}}
{{- $height = $height | default .Height -}}
{{- end -}}

{{- $small := .SrcSmall | default $src -}}
Expand All @@ -21,18 +25,22 @@
<img
class="lazyload{{ with .Class }} {{ . }}{{ end }}"
src="{{ $loading.RelPermalink }}"
data-src="{{ .Src | safeURL }}"
data-srcset="{{ $small | safeURL }}, {{ .Src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-src="{{ $src | safeURL }}"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-sizes="auto"
alt="{{ $alt }}"{{ with .Height }} height="{{ . }}"{{ end }}{{ with .Width }} width="{{ . }}"{{ end }} />
alt="{{ $alt }}"
{{- with $width }} width="{{ . }}"{{ end }}
{{- with $height }} height="{{ . }}"{{ end }} />
</a>
{{- else -}}
<img
class="lazyload{{ with .Class }} {{ . }}{{ end }}"
src="{{ $loading.RelPermalink }}"
data-src="{{ .Src | safeURL }}"
data-srcset="{{ $small | safeURL }}, {{ .Src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-src="{{ $src | safeURL }}"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-sizes="auto"
alt="{{ $alt }}"
title="{{ .Title | default $alt }}"{{ with .Height }} height="{{ . }}"{{ end }}{{ with .Width }} width="{{ . }}"{{ end }} />
title="{{ .Title | default $alt }}"
{{- with $width }} width="{{ . }}"{{ end }}
{{- with $height }} height="{{ . }}"{{ end }} />
{{- end -}}

Large diffs are not rendered by default.

0 comments on commit 428d8b8

Please sign in to comment.