add comments and refactor more

This commit is contained in:
Aditya Telange 2024-11-09 20:52:28 +05:30
parent 86b5018dfe
commit cb1059e04d
No known key found for this signature in database
GPG Key ID: 82E844EF3DA99E77

View File

@ -10,6 +10,8 @@
{{- $pageBundleCover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- $globalResourcesCover := (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
{{- $cover := (or $pageBundleCover $globalResourcesCover)}}
{{/* We are not using the .Param.cover.relative to decide the location of image */}}
{{/* If we have the image in pageBundle or globalResources we can process the image */}}
{{- $sizes := (slice "360" "480" "720" "1080" "1500") }}
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
@ -26,7 +28,8 @@
<a href="{{ $imgdl }}" target="_blank" rel="noopener noreferrer">
{{- end }}
{{- if $cover -}}{{/* i.e it is present in page bundle */}}
{{- if $cover -}}
{{/* i.e it is present in page bundle */}}
{{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }}
<img loading="{{$loading}}"
srcset='{{- range $size := $sizes -}}
@ -42,7 +45,8 @@
{{- else }}{{/* Unprocessable image or responsive images disabled */}}
<img loading="{{ $loading }}" src="{{ $imgdl }}" alt="{{ $alt }}">
{{- end }}
{{- else }}{{/* For absolute urls and external links, no img processing here */}}
{{- else }}
{{/* For absolute urls and external links, no img processing here */}}
<img loading="{{ $loading }}" src="{{ $imgdl }}" alt="{{ $alt }}">
{{- end }}