Skip to content

Commit

Permalink
feat: add more parameters for image partial, Height, Width and Alignm…
Browse files Browse the repository at this point in the history
…ent (#39)
  • Loading branch information
razonyang committed Jan 13, 2024
1 parent ddfe37b commit e0723aa
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions layouts/partials/images/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
{{/* - Original : whether to describe the original image info via data-* attributes, default to false. */}}
{{/* - LazyLoading : whether enable lazy loading, default true. */}}
{{/* - Style : additional inline style for <img> tag. */}}
{{/* - Height : the natural height of image, typically used for external image. */}}
{{/* - Width : the natural width of image, typically used for external image. */}}
{{/* - Alignment : the alignment of image. */}}
{{- $formats := slice "bmp" "jpeg" "jpg" "png" "tif" "tiff" "webp" }}
{{- $modernFormat := "webp" }}
{{- $siteParams := partialCached "images/functions/params" . }}
Expand All @@ -27,16 +30,16 @@
{{- $alt := default "" .Alt }}
{{- $caption := default "" .Caption }}
{{- $className := default (default "img-fluid" $siteParams.class_name) .ClassName }}
{{- $height := default "" ($params.Get "height" | strings.TrimSuffix "px") }}
{{- $height := default (default "" .Height) ($params.Get "height" | strings.TrimSuffix "px") }}
{{- $originalHeight := 0 }}
{{- $naturalHeight := $height }}
{{- $width := default "" ($params.Get "width" | strings.TrimSuffix "px") }}
{{- $width := default (default "" .Width) ($params.Get "width" | strings.TrimSuffix "px") }}
{{- $originalWidth := 0 }}
{{- $naturalWidth := $width }}
{{- $wrapperClass := "" }}
{{- $sources := slice }}
{{/* Image alignment. */}}
{{- $alignment := $url.Fragment }}
{{- $alignment := default .Alignment $url.Fragment }}
{{- if eq $alignment "center" }}
{{- $wrapperClass = default "d-block text-center" $siteParams.alignment_center_class_name }}
{{- else if eq $alignment "float-start" }}
Expand Down

0 comments on commit e0723aa

Please sign in to comment.