Skip to content

Commit

Permalink
fix: remove unit from width and height attributes for public images (#46
Browse files Browse the repository at this point in the history
)

fix: add unit for width and height inline style attributes
  • Loading branch information
razonyang committed Mar 9, 2024
1 parent 17883d8 commit 461c269
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions layouts/partials/images/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -160,8 +160,8 @@
{{/* Process static image. */}}
{{- $src = absURL $url.Path }}
{{- with imageConfig $filepath }}
{{- $naturalHeight = printf "%dpx" .Height }}
{{- $naturalWidth = printf "%dpx" .Width }}
{{- $naturalHeight = .Height }}
{{- $naturalWidth = .Width }}
{{- end }}
{{/* hash by the date. */}}
{{- $hash := "" }}
Expand Down Expand Up @@ -190,10 +190,10 @@
{{- if $src }}
{{/* Inline style. */}}
{{- if and $height (ne $height $naturalHeight) }}
{{- $style = $style | append (printf "height: %s" $height) }}
{{- $style = $style | append (printf "height: %spx" $height) }}
{{- end }}
{{- if and $width (ne $width $naturalWidth) }}
{{- $style = $style | append (printf "width: %s" $width) }}
{{- $style = $style | append (printf "width: %spx" $width) }}
{{- end }}
{{- $ctx := dict
"sources" $sources
Expand Down

0 comments on commit 461c269

Please sign in to comment.