From 40e720df8b92435634184f8c6a19d9e66e13c52f Mon Sep 17 00:00:00 2001 From: razonyang Date: Mon, 3 Jul 2023 14:57:11 +0800 Subject: [PATCH] feat: add the Style parameter for additional inline style Move the partial images/functions/picture to images/picture --- layouts/partials/images/image.html | 7 ++++--- layouts/partials/images/{functions => }/picture.html | 0 2 files changed, 4 insertions(+), 3 deletions(-) rename layouts/partials/images/{functions => }/picture.html (100%) diff --git a/layouts/partials/images/image.html b/layouts/partials/images/image.html index bc9cadd..228bd93 100644 --- a/layouts/partials/images/image.html +++ b/layouts/partials/images/image.html @@ -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 tag. */}} {{- $formats := slice "bmp" "gif" "jpeg" "jpg" "png" "tif" "tiff" "webp" }} {{- $modernFormat := "webp" }} {{- if isset site.Params.images "modern_format" }} @@ -19,6 +20,7 @@ {{- $params := $url.Query }} {{/* Initialize image properties. */}} {{- $src := "" }} +{{- $style := default slice .Style }} {{- $original := default false .Original }} {{- $originalSrc := "" }} {{- $alt := default "" .Alt }} @@ -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 }} @@ -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 }}
- {{ 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))) }}
{{ $caption }}
{{- else }} - {{ partial "images/functions/picture" (merge $ctx (dict "wrapperClass" $wrapperClass)) }} + {{ partial "images/picture" (merge $ctx (dict "wrapperClass" $wrapperClass)) }} {{- end }} {{- end -}} diff --git a/layouts/partials/images/functions/picture.html b/layouts/partials/images/picture.html similarity index 100% rename from layouts/partials/images/functions/picture.html rename to layouts/partials/images/picture.html