Skip to content

Commit

Permalink
feat: add the Style parameter for additional inline style
Browse files Browse the repository at this point in the history
Move the partial images/functions/picture to images/picture
  • Loading branch information
razonyang committed Jul 3, 2023
1 parent 23746b3 commit 40e720d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions layouts/partials/images/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
{{/* - ClassName : the class name of the img tag, optional. */}}
{{/* - 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. */}}
{{- $formats := slice "bmp" "gif" "jpeg" "jpg" "png" "tif" "tiff" "webp" }}
{{- $modernFormat := "webp" }}
{{- if isset site.Params.images "modern_format" }}
Expand All @@ -19,6 +20,7 @@
{{- $params := $url.Query }}
{{/* Initialize image properties. */}}
{{- $src := "" }}
{{- $style := default slice .Style }}
{{- $original := default false .Original }}
{{- $originalSrc := "" }}
{{- $alt := default "" .Alt }}
Expand Down Expand Up @@ -180,7 +182,6 @@
{{- end }}
{{- if $src }}
{{/* Inline style. */}}
{{- $style := slice }}
{{- if and $height (ne $height $naturalHeight) }}
{{- $style = $style | append (printf "height: %s" $height) }}
{{- end }}
Expand All @@ -206,10 +207,10 @@
{{- $figureCaptionClass := default "figure-caption" site.Params.images.figure_caption_class_name }}
{{- $figureImgClass := default "figure-img" site.Params.images.figure_image_class_name }}
<figure class="{{ $figureClass }} {{ $wrapperClass }}">
{{ partial "images/functions/picture" (merge $ctx (dict "className" (printf "%s %s" $figureImgClass $className))) }}
{{ partial "images/picture" (merge $ctx (dict "className" (printf "%s %s" $figureImgClass $className))) }}
<figcaption class="{{ $figureCaptionClass }}">{{ $caption }}</figcaption>
</figure>
{{- else }}
{{ partial "images/functions/picture" (merge $ctx (dict "wrapperClass" $wrapperClass)) }}
{{ partial "images/picture" (merge $ctx (dict "wrapperClass" $wrapperClass)) }}
{{- end }}
{{- end -}}
File renamed without changes.

0 comments on commit 40e720d

Please sign in to comment.