Skip to content

Commit

Permalink
Revert ":rewind: Revert: restore image data-alt to alt"
Browse files Browse the repository at this point in the history
This reverts commit 6c6a326.
  • Loading branch information
Lruihao committed Jan 28, 2024
1 parent b7dba07 commit 01b3ec2
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions layouts/partials/plugin/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{{- /* for details, see https://lruihao.cn/posts/native-img-loading-lazy/ */ -}}
{{- if eq $loading "lazy" -}}
{{- /* TODO move to theme.js */ -}}
{{- $commonScript := "this.title=this.dataset.title;for(const i of ['style', 'data-title','onerror','onload']){this.removeAttribute(i);}" -}}
{{- $commonScript := "this.title=this.dataset.title;this.alt=this.dataset.alt;for(const i of ['style', 'data-title','data-alt','onerror','onload']){this.removeAttribute(i);}" -}}
{{- $onload = printf " onload=\"%vthis.dataset.lazyloaded='';\"" $commonScript | safeHTMLAttr -}}
{{- $onerror = printf " onerror=\"%v\"" $commonScript | safeHTMLAttr -}}
{{- $style = printf " style=\"%vbackground: url(%v) no-repeat center;\"" $style (resources.Get "images/loading.svg" | minify).RelPermalink | safeHTMLAttr -}}
Expand All @@ -87,10 +87,10 @@
{{- if .Linked -}}
<a class="lightgallery" href="{{ $srcLarge | safeURL }}" data-thumbnail="{{ $srcSmall | safeURL }}"{{ with $caption }} data-sub-html="<h2>{{ . }}</h2>{{ with $.Title }}<p>{{ . }}</p>{{ end }}"{{ end }}{{ with .Rel }} rel="{{ . }}"{{ end }}>
{{- end -}}
<img loading="{{ $loading }}" src="{{ $src | safeURL }}" alt="{{ $alt }}"
<img loading="{{ $loading }}" src="{{ $src | safeURL }}"
{{- if .Responsive }} srcset="{{ $srcSmall | safeURL }}, {{ $srcMedium | safeURL }} 1.5x, {{ $srcLarge | safeURL }} 2x" sizes="auto"{{- end -}}
{{- if eq $loading "lazy" }} data-title="{{ .Title | default $alt }}"
{{- else }} title="{{ .Title | default $alt }}"{{- end -}}
{{- if eq $loading "lazy" }} data-title="{{ .Title | default $alt }}" data-alt="{{ $alt }}"
{{- else }} title="{{ .Title | default $alt }}" alt="{{ $alt }}"{{- end -}}
{{- with .Width }} width="{{ . }}"{{- end -}}
{{- with .Height }} height="{{ . }}"{{- end -}}
{{- with $class }} class="{{ trim . " " }}"{{- end -}}
Expand Down

1 comment on commit 01b3ec2

@vercel
Copy link

@vercel vercel bot commented on 01b3ec2 Jan 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.