Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix anchor link positioning #283

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions layouts/partials/plugin/image.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
{{- $height = $height | default .Height -}}
{{- end -}}
{{- end -}}
{{- /* lazysize.js causes inaccurate positioning for anchor links, don't activate it if no alternatives */ -}}
{{- $responsive := ne (or .SrcSmall .SrcLarge) nil -}}

{{- $style := "" -}}
{{- with $width -}}
Expand All @@ -36,11 +38,15 @@
{{- if .Linked -}}
<a class="lightgallery" href="{{ $large | safeURL }}" data-thumbnail="{{ $small | safeURL }}"{{ with $caption }} data-sub-html="<h2>{{ . }}</h2>{{ with $.Title }}<p>{{ . }}</p>{{ end }}"{{ end }}{{ with .Rel }} rel="{{ . }}"{{ end }}>
<img
class="lazyload{{ with .Class }} {{ . }}{{ end }}"
class="{{ if $responsive }}lazyload{{ end }}{{ with .Class }} {{ . }}{{ end }}"
{{ if $responsive }}
src="{{ $loading.RelPermalink }}"
data-src="{{ $src | safeURL }}"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-sizes="auto"
{{ else }}
src="{{ $src | safeURL }}"
{{ end }}
alt="{{ $alt }}"
title="{{ .Title | default $alt }}"
{{- with $width }} width="{{ . }}"{{- end -}}
Expand All @@ -51,11 +57,15 @@
</a>
{{- else -}}
<img
class="lazyload{{ with .Class }} {{ . }}{{ end }}"
class="{{ if $responsive }}lazyload{{ end }}{{ with .Class }} {{ . }}{{ end }}"
{{ if $responsive }}
src="{{ $loading.RelPermalink }}"
data-src="{{ $src | safeURL }}"
data-srcset="{{ $small | safeURL }}, {{ $src | safeURL }} 1.5x, {{ $large | safeURL }} 2x"
data-sizes="auto"
{{ else }}
src="{{ $src | safeURL }}"
{{ end }}
alt="{{ $alt }}"
title="{{ .Title | default $alt }}"
{{- with $width }} width="{{ . }}"{{- end -}}
Expand Down