mirror of
https://github.com/adityatelange/hugo-PaperMod.git
synced 2025-02-05 08:08:05 -05:00
add comments and refactor more
This commit is contained in:
parent
86b5018dfe
commit
cb1059e04d
@ -10,6 +10,8 @@
|
|||||||
{{- $pageBundleCover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
|
{{- $pageBundleCover := (.Resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
|
||||||
{{- $globalResourcesCover := (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
|
{{- $globalResourcesCover := (resources.ByType "image").GetMatch (printf "*%s*" (.Params.cover.image)) }}
|
||||||
{{- $cover := (or $pageBundleCover $globalResourcesCover)}}
|
{{- $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") }}
|
{{- $sizes := (slice "360" "480" "720" "1080" "1500") }}
|
||||||
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
|
{{- $processableFormats := (slice "jpg" "jpeg" "png" "tif" "bmp" "gif") -}}
|
||||||
@ -26,7 +28,8 @@
|
|||||||
<a href="{{ $imgdl }}" target="_blank" rel="noopener noreferrer">
|
<a href="{{ $imgdl }}" target="_blank" rel="noopener noreferrer">
|
||||||
{{- end }}
|
{{- 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)) }}
|
{{- if (and (in $processableFormats $cover.MediaType.SubType) ($responsiveImages) (eq $prod true)) }}
|
||||||
<img loading="{{$loading}}"
|
<img loading="{{$loading}}"
|
||||||
srcset='{{- range $size := $sizes -}}
|
srcset='{{- range $size := $sizes -}}
|
||||||
@ -42,7 +45,8 @@
|
|||||||
{{- else }}{{/* Unprocessable image or responsive images disabled */}}
|
{{- else }}{{/* Unprocessable image or responsive images disabled */}}
|
||||||
<img loading="{{ $loading }}" src="{{ $imgdl }}" alt="{{ $alt }}">
|
<img loading="{{ $loading }}" src="{{ $imgdl }}" alt="{{ $alt }}">
|
||||||
{{- end }}
|
{{- 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 }}">
|
<img loading="{{ $loading }}" src="{{ $imgdl }}" alt="{{ $alt }}">
|
||||||
{{- end }}
|
{{- end }}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user