Lazy loading of images

This commit is contained in:
2024-02-25 13:23:26 +11:00
parent 4917bc1aa1
commit 2a5bf8ee76
8 changed files with 13 additions and 13 deletions

View File

@@ -2,8 +2,8 @@
- post.photos.each_with_index do |photo, idx|
div class="rounded max-w-xs"
a href="#{post.permalink}#photo-#{idx}"
img class="rounded object-cover transition-transform ease-out hover:scale-105 h-48 w-48" src="#{photo["value"]}" alt="#{photo["alt"]}"
img loading="lazy" class="rounded object-cover transition-transform ease-out hover:scale-105 h-48 w-48" src="#{photo["value"]}" alt="#{photo["alt"]}"
- else
div class="rounded max-w-xs"
a href="#{post.permalink}"
img class="rounded object-cover transition-transform ease-out hover:scale-105 h-48 w-48" src="#{post.photos[0]["value"]}" alt="#{post.photos[0]["alt"]}"
img loading="lazy" class="rounded object-cover transition-transform ease-out hover:scale-105 h-48 w-48" src="#{post.photos[0]["value"]}" alt="#{post.photos[0]["alt"]}"

View File

@@ -6,7 +6,7 @@ div class="mb-8 h-entry"
== post.excerpt
div class="grid gap-4 grid-flow-row grid-cols-#{post.photos.count} grid-rows-1"
-post.photos.each do |photo|
img class="w-44 h-44 object-cover rounded" src=photo["value"]
img loading="lazy" class="w-44 h-44 object-cover rounded" src=photo["value"]
/ == render "shared/tags", tags: post.tags
p class="text-sm text-blue-400 dark:text-indigo-400"

View File

@@ -4,7 +4,7 @@ div class="mb-8 h-entry border border-gray-200 m-2 p-4 bg-gray-50 hover:bg-gray-
== " 💬 #{post.raw_content}"
div class="grid gap-4 grid-flow-row grid-cols-4 grid-rows-1"
-post.photos.each do |photo|
img class="w-32 h-32 object-cover rounded" src=photo["value"]
img loading="lazy" class="w-32 h-32 object-cover rounded" src=photo["value"]
== render "shared/tags", tags: post.tags
div class="mb-8"