diff --git a/hugo-modules/core/utils/asset/image/img.html b/hugo-modules/core/utils/asset/image/img.html index 04eacdb..ade4571 100644 --- a/hugo-modules/core/utils/asset/image/img.html +++ b/hugo-modules/core/utils/asset/image/img.html @@ -3,7 +3,7 @@ Render Contentful asset (image/...). Uses data from cssg-plugin-assets if available. @example - Go Template - {{- partial "utils/asset/image" (dict + {{- partial "utils/asset/image/img" (dict "context" $image "options" (dict "sizes" "(max-width: 768px) 100vw, 768px" @@ -51,7 +51,7 @@ {{- $width := .width -}} {{- $height := .height -}} {{/* Preload hint is added in sources.html */}} - {{- $alt -}} + {{- $alt -}} {{- end -}} {{- else -}} {{- with $url -}} diff --git a/hugo-modules/core/utils/asset/image/sources.html b/hugo-modules/core/utils/asset/image/sources.html index 70861b7..d4f6029 100644 --- a/hugo-modules/core/utils/asset/image/sources.html +++ b/hugo-modules/core/utils/asset/image/sources.html @@ -3,7 +3,7 @@ Render Contentful asset (image/...). Uses data from cssg-plugin-assets if available. @example - Go Template - {{- partial "utils/asset/image" (dict + {{- partial "utils/asset/image/sources" (dict "context" $image "options" (dict "sizes" "(max-width: 768px) 100vw, 768px" @@ -53,7 +53,7 @@ {{- range $srcsets -}} {{ $srcset := .srcset | default "" }} {{ $type := .type | default ""}} - + {{- $preload_attr := (dict "as" "image" "imagesizes" $local_sizes diff --git a/hugo-modules/core/utils/asset/svg.html b/hugo-modules/core/utils/asset/svg.html index 0a7f051..cf2b360 100644 --- a/hugo-modules/core/utils/asset/svg.html +++ b/hugo-modules/core/utils/asset/svg.html @@ -6,7 +6,7 @@ {{- partial "utils/asset/svg" (dict "context" $svg "options" (dict - "inline" "true" + "inline" true "class_name" "c-icon" "lazy" true ) diff --git a/hugo-modules/core/utils/asset/video.html b/hugo-modules/core/utils/asset/video.html index aeb0c2f..8371b96 100644 --- a/hugo-modules/core/utils/asset/video.html +++ b/hugo-modules/core/utils/asset/video.html @@ -3,12 +3,12 @@ Render Contentful asset (video/...). Uses data from cssg-plugin-assets if available. @example - Go Template - {{- partial "utils/asset/svg" (dict + {{- partial "utils/asset/video" (dict "context" $video "options" (dict - "loop" "false" - "muted" "false" - "autoplay" "false" + "loop" false + "muted" false + "autoplay" false "class_name" "c-video" ) ) -}} @@ -26,9 +26,10 @@ {{- $autoplay := $params.autoplay | default true -}} {{- $playsinline := $params.playsinline | default true -}} {{- $controls := $params.controls | default false -}} -{{- $poster := $params.poster | default false -}} +{{/* Use transparent base64, the real poster should be loaded as element */}} +{{- $poster := "data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7" -}} {{- $muted := (or $autoplay $params.muted) -}} -{{- $loading := cond (eq $params.lazy true) "lazy" ($params.loading | default false) -}} +{{- $loading := cond (eq ($params.lazy | default true) true) "lazy" ($params.loading | default false) -}} {{- $preload := $params.preload | default false -}} {{- $media := $params.media -}} @@ -39,18 +40,11 @@ "controls" $controls "class" $class_name "poster" $poster + "loading" $loading ) $params -}} {{- if in $mime_type "video" -}} - {{- $preload_attr := (dict - "as" "image" - "href" $poster - "media" $media - ) -}} - {{- if and $preload $poster (not (in ($globals.Scratch.Get "preload") $preload)) -}} - {{- $globals.Scratch.Add "preload" (slice $preload) -}} - {{- end -}} -