Skip to content

Commit

Permalink
refactor(image): reduce deplicated img item
Browse files Browse the repository at this point in the history
  • Loading branch information
HEIGE-PCloud committed May 11, 2024
1 parent 2840a44 commit ef455fb
Showing 1 changed file with 2 additions and 15 deletions.
17 changes: 2 additions & 15 deletions layouts/partials/plugin/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@

{{- if .Linked -}}
<a class="lightgallery" href="{{ $large.RelPermalink | safeURL }}" title="{{ .Title | default $alt }}" data-thumbnail="{{ $small.RelPermalink | safeURL }}"{{ with .Caption }} data-sub-html="<h2>{{ . }}</h2>{{ with $.Title }}<p>{{ . }}</p>{{ end }}"{{ end }}{{ with .Rel }} rel="{{ . }}"{{ end }}>
{{- end -}}
<img
{{ with .Class }}class="{{ . }}"{{ end }}
loading="{{ $loading }}"
Expand All @@ -45,20 +46,6 @@
{{- end -}}
"
alt="{{ $alt }}"{{ with $height }} height="{{ . }}" {{ end }}{{ with $width }} width="{{ . }}" {{ end }}>
{{- if .Linked -}}
</a>
{{- else -}}
<img
{{ with .Class }}class="{{ . }}"{{ end }}
loading="{{ $loading }}"
src="{{ $default.RelPermalink | safeURL }}"
srcset="
{{- if eq $optimized false -}}
{{ $small.RelPermalink | safeURL }}, {{ $default.RelPermalink | safeURL }} 1.5x, {{ $large.RelPermalink | safeURL }} 2x
{{- else -}}
{{ $small.RelPermalink | safeURL }} {{ $small.Width }}w,
{{ $default.RelPermalink | safeURL }} {{ $default.Width }}w,
{{ $large.RelPermalink | safeURL }} {{ $large.Width }}w
{{- end -}}
"
title="{{ .Title | default $alt }}"{{ with $height }} height="{{ . }}" {{ end }} {{ with $width }} width="{{ . }}" {{ end }}>
{{- end -}}

0 comments on commit ef455fb

Please sign in to comment.