diff --git a/CHANGELOG.md b/CHANGELOG.md index b5d81506..92037186 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -37,6 +37,7 @@ All notable changes to this project will be documented in this file. - :bug: Fix: `center-quote` shortcode rendering error when config `unsafe = false` (@yureiita[#160](https://github.com/hugo-fixit/FixIt/pull/160)) - :bug: Fix: menu item invalid params `draft` in submenu - :bug: Fix: missing height and weight of img element and lazyload object-fit style +- :bug: Fix: image shortcode invalid params `height` and `weight` ([#200](https://github.com/hugo-fixit/FixIt/issues/200)) - :bug: Fix: typeit shortcode invalid config `duration = -1` and fix style - :bug: Fix: typeit shortcode prints consecutive spaces and newline errors - :art: Style: change the default icons of some social links diff --git a/assets/css/_page/_single.scss b/assets/css/_page/_single.scss index f829f0ec..fa254b42 100644 --- a/assets/css/_page/_single.scss +++ b/assets/css/_page/_single.scss @@ -71,10 +71,10 @@ height: auto; margin: 0 auto; overflow: hidden; - } - img.lazyloaded { - width: 100%; + &.lazyloaded { + width: 100%; + } } } @@ -290,7 +290,7 @@ margin: 0 auto; overflow: hidden; - &.lazyloaded { + &.lazyloaded:not([data-w]) { width: 100%; } } @@ -301,7 +301,7 @@ @include object-fit(none); } - .lazyloaded { + .lazyloaded:not([data-h]) { @include object-fit(fill); } diff --git a/docs b/docs index fe8f4106..d805b776 160000 --- a/docs +++ b/docs @@ -1 +1 @@ -Subproject commit fe8f41062c71062ab3df45cb7240128ad939008f +Subproject commit d805b776401c7369218e78ad4e92f0fa812b6c4b diff --git a/layouts/partials/plugin/image.html b/layouts/partials/plugin/image.html index 4a0aab45..04ae79bb 100644 --- a/layouts/partials/plugin/image.html +++ b/layouts/partials/plugin/image.html @@ -8,6 +8,15 @@ {{- $height = $height | default .Height -}} {{- end -}} +{{- $style := "" -}} +{{- with $width -}} + {{- $style = printf "width: %v;" . -}} +{{- end -}} +{{- with $height -}} + {{- $style = printf "%vheight: %v;" $style . -}} +{{- end -}} +{{- /* with $style }} {{ printf "style=\"%v\"" $style | safeHTMLAttr -}}{{- end */ -}} + {{- $small := .SrcSmall | default $src -}} {{- with dict "Path" .SrcSmall "Resources" .Resources | partial "function/resource.html" -}} {{- $small = .RelPermalink -}} @@ -31,8 +40,10 @@ data-sizes="auto" alt="{{ $alt }}" title="{{ .Title | default $alt }}" - {{- with .Height }} height="{{ . }}"{{- end -}} - {{- with .Width }} width="{{ . }}"{{- end -}} + {{- with $width }} width="{{ . }}"{{- end -}} + {{- with $height }} height="{{ . }}"{{- end -}} + {{- with .Width }} data-w{{- end -}} + {{- with .Height }} data-h{{- end -}} /> {{- else -}} @@ -46,5 +57,7 @@ title="{{ .Title | default $alt }}" {{- with $width }} width="{{ . }}"{{- end -}} {{- with $height }} height="{{ . }}"{{- end -}} + {{- with .Width }} data-w{{- end -}} + {{- with .Height }} data-h{{- end -}} /> {{- end -}}