Minify home images
This commit is contained in:
@@ -6,6 +6,7 @@ require "rexml/parsers/pullparser"
|
|||||||
require "sanitize"
|
require "sanitize"
|
||||||
require "nokogiri"
|
require "nokogiri"
|
||||||
require "unicode/emoji"
|
require "unicode/emoji"
|
||||||
|
require "mini_magick"
|
||||||
|
|
||||||
module Main
|
module Main
|
||||||
module Decorators
|
module Decorators
|
||||||
@@ -32,6 +33,12 @@ module Main
|
|||||||
__getobj__.photos.select { |p| !p["value"].end_with?("mp4") }
|
__getobj__.photos.select { |p| !p["value"].end_with?("mp4") }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def photo_thumbnails
|
||||||
|
photos.map do |photo|
|
||||||
|
photo["value"] = photo["value"].gsub(".jpeg", "-small.jpeg")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def videos?
|
def videos?
|
||||||
__getobj__.photos.count { |p| p["value"].end_with?("mp4") } > 0
|
__getobj__.photos.count { |p| p["value"].end_with?("mp4") } > 0
|
||||||
end
|
end
|
||||||
|
@@ -1,13 +1,13 @@
|
|||||||
- if extended
|
- if extended
|
||||||
- post.photos.each_with_index do |photo, idx|
|
- post.photo_thumbnails.each_with_index do |photo, idx|
|
||||||
div class="rounded max-w-xs"
|
div class="rounded max-w-xs"
|
||||||
a href="#{post.permalink}#photo-#{idx}"
|
a href="#{post.permalink}#photo-#{idx}"
|
||||||
img loading="lazy" 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}" alt="#{photo["alt"]}"
|
||||||
- else
|
- else
|
||||||
- if post.photos.count > 0
|
- if post.photos.count > 0
|
||||||
div class="rounded max-w-xs"
|
div class="rounded max-w-xs"
|
||||||
a href="#{post.permalink}"
|
a href="#{post.permalink}"
|
||||||
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"]}"
|
img loading="lazy" class="rounded object-cover transition-transform ease-out hover:scale-105 h-48 w-48" src="#{post.photo_thumbnails[0]}" alt="#{post.photos[0]["alt"]}"
|
||||||
- if post.videos.count > 0
|
- if post.videos.count > 0
|
||||||
div class="rounded max-w-xs"
|
div class="rounded max-w-xs"
|
||||||
a href="#{post.permalink}"
|
a href="#{post.permalink}"
|
||||||
|
@@ -11,7 +11,7 @@ module Main
|
|||||||
end
|
end
|
||||||
|
|
||||||
private_expose :date do
|
private_expose :date do
|
||||||
TZInfo::Timezone.get('Australia/Canberra').now
|
TZInfo::Timezone.get("Australia/Canberra").now
|
||||||
end
|
end
|
||||||
|
|
||||||
expose :formatted_date do |date|
|
expose :formatted_date do |date|
|
||||||
|
Reference in New Issue
Block a user