Skip to content

Commit

Permalink
chore: add more comments
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud committed May 23, 2024
1 parent 47d185c commit 7ffe97b
Showing 1 changed file with 9 additions and 26 deletions.
35 changes: 9 additions & 26 deletions layouts/partials/plugin/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,18 +7,20 @@
or a global resource (inside the assets directory) https://gohugo.io/functions/resources/get/
or a link to a remote resource, which can be cached if the site parameter is set https://gohugo.io/functions/resources/getremote/
- Resources: If the image is a page resource, this parameter is required. It is the .Resources of the page.
- Optim: optimisation parameter, defined like
{{- $optim := slice
(dict "Process" "fill 800x240 Center webp q75" "descriptor" "800w")
(dict "Process" "fill 1200x360 Center webp q75" "descriptor" "1200w")
(dict "Process" "fill 1600x480 Center webp q75" "descriptor" "1600w")
-}}
See https://gohugo.io/content-management/image-processing/ for more information.
*/}}


{{- $resource := (.Resources.Get .Src) | default (resources.Get .Src) | default nil -}}

{{- $cacheRemote := true -}}
{{/* {{- $optim := slice
(dict "Process" "fill 800x240 Center webp q75" "descriptor" "800w")
(dict "Process" "fill 1200x360 Center webp q75" "descriptor" "1200w")
(dict "Process" "fill 1600x480 Center webp q75" "descriptor" "1600w")
-}} */}}
{{- $optim := .Optim -}}

{{- if not $resource | and (partial "function/isUrlRemote.html" (urls.Parse .Src)) | and $cacheRemote -}}
{{- with $remoteResource := resources.GetRemote .Src -}}
{{- with .Err -}}
Expand All @@ -31,6 +33,7 @@
{{- end -}}
{{- end -}}

{{- $optim := .Optim -}}
{{- $srcset := "" -}}
{{- if $optim | and $resource -}}
{{ $srcsetSlice := slice -}}
Expand All @@ -51,26 +54,6 @@
<img {{ with .Class }}class="{{ . }}"{{ end }} {{ with .Loading }}loading="{{ . }}"{{ end }} src="{{ $src }}" {{ with $srcset }}srcset="{{ . }}"{{ end }} {{ with .Sizes }}sizes="{{ . }}"{{ end }} {{ with $alt }}alt=""{{ end }} {{ with $height }}height="{{ . }}"{{ end }} {{ with $width }}width="{{ . }}"{{ end }}>


{{/* {{- with $resource -}}
<h1>
<p>
{{- $resource -}}
</p>
<p>
{{- $resource.Width -}}
</p>
<p>
{{- $resource.Height -}}
</p>
</h1>
{{- else -}}
<h1>
<p>.Resource.Get and resources.Get failed</p>
<p>This resource is not a page resource nor a global resources</p>
{{- .Src -}}
</h1>
{{- end -}} */}}

{{/*
{{- $remote := .Remote | default false -}}
{{- $optimize := .Optim | default false -}}
Expand Down

0 comments on commit 7ffe97b

Please sign in to comment.