Skip to content

Commit

Permalink
LQIP prototype
Browse files Browse the repository at this point in the history
  • Loading branch information
stereobooster committed Sep 11, 2023
1 parent 22e1f17 commit bfae279
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions exampleSite/content/samples/markdown/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ This article offers a sample of basic Markdown formatting that can be used in Co

<!--more-->

## Image

![sample image](thumb-surendran-mp-IhWYiwSxm8g-unsplash.jpg)

## Headings

The following HTML `<h1>``<h6>` elements represent six levels of section headings. `<h1>` is the highest section level while `<h6>` is the lowest.
Expand Down
8 changes: 8 additions & 0 deletions layouts/_default/_markup/render-image.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
{{ end }}
{{ with $resource }}
<figure>
{{ if ne .MediaType.SubType "svg" }}
{{ $lqip := .Resize "20x webp" }}
<div class="mx-auto my-0 rounded-md"
style="background: url(data:image/webp;base64,{{ $lqip.Content | base64Encode }}); background-size: cover">
{{ end }}
<img
class="mx-auto my-0 rounded-md"
{{ if eq .MediaType.SubType "svg" }}
Expand All @@ -46,6 +51,9 @@
loading="lazy"
{{ end }}
/>
{{ if ne .MediaType.SubType "svg" }}
</div>
{{ end }}
{{ with $caption }}<figcaption class="text-center">{{ . | markdownify }}</figcaption>{{ end }}
</figure>
{{ else }}
Expand Down

0 comments on commit bfae279

Please sign in to comment.