parent
a6d96dbdc2
commit
9ab6b65570
6 changed files with 126 additions and 9 deletions
Before Width: | Height: | Size: 400 KiB |
@ -0,0 +1,20 @@ |
||||
window.addEventListener("load", () => { |
||||
document.querySelectorAll("figure.enlargable").forEach(node => { |
||||
node.addEventListener("click", () => { |
||||
console.log("Hey"); |
||||
node.classList.toggle("enlarged") |
||||
}) |
||||
}) |
||||
|
||||
const keyDown = (e) => { |
||||
if (e.keyCode !== 27) { |
||||
return |
||||
} |
||||
|
||||
document.querySelectorAll("figure.enlarged").forEach(node => { |
||||
node.classList.remove("enlarged") |
||||
}) |
||||
} |
||||
|
||||
document.addEventListener('keydown', keyDown) |
||||
}) |
@ -1,5 +1,34 @@ |
||||
{{- $img := resources.Get .path }} |
||||
{{- $img = $img.Resize (printf "%dx%d webp" $img.Width $img.Height) }} |
||||
<img src="{{ $img.Permalink }}" alt="{{ .alt | default "" }}" width="{{ .width | default $img.Width }}" |
||||
height="{{ .height | default $img.Height }}" {{- if .class}}class="{{ .class }}" {{end}} |
||||
{{- if .style}}style="{{ .style | safeCSS }}" {{end}} /> |
||||
{{- $orignal := resources.Get .path }} |
||||
{{- $png := $orignal.Resize (printf "%dx%d png q50" $orignal.Width $orignal.Height) }} |
||||
{{- $webp := $orignal.Resize (printf "%dx%d webp q50" $orignal.Width $orignal.Height) }} |
||||
{{- $pngFull := $orignal.Resize (printf "%dx%d webp q100" $orignal.Width $orignal.Height) }} |
||||
{{- $webpFull := $orignal.Resize (printf "%dx%d webp q100" $orignal.Width $orignal.Height) }} |
||||
<picture> |
||||
<source type="image/webp" srcset="{{ $webp.Permalink }}"> |
||||
<img |
||||
src="{{ $png.Permalink }}" |
||||
alt="{{ .alt | default "" }}" |
||||
title="{{ .alt }}" |
||||
width="{{ .width | default $png.Width }}" |
||||
height="{{ .height | default $png.Height }}" |
||||
{{- if .class}}class="{{ .class }}" {{end}} |
||||
{{- if .style}}style="{{ .style | safeCSS }}" {{end}} /> |
||||
</picture> |
||||
|
||||
<div class="enlarged_image"> |
||||
<picture> |
||||
<source type="image/webp" srcset="{{ $webpFull.Permalink }}"> |
||||
<img |
||||
src="{{ $pngFull.Permalink }}" |
||||
alt="{{ .alt | default "" }}" |
||||
loading="lazy" |
||||
title="{{ .alt }}" |
||||
width="{{ .width | default $pngFull.Width }}" |
||||
height="{{ .height | default $pngFull.Height }}" |
||||
{{- if .class}}class="{{ .class }}" {{end}} |
||||
{{- if .style}}style="{{ .style | safeCSS }}" {{end}} /> |
||||
</picture> |
||||
{{- with .alt }} |
||||
<p class="caption">{{ . }}</p> |
||||
{{- end }} |
||||
</div> |
||||
|
Loading…
Reference in new issue