Skip to content

Commit

Permalink
fix thumbnails 5
Browse files Browse the repository at this point in the history
  • Loading branch information
s7uck committed Aug 17, 2024
1 parent 136bbc2 commit 02b1b43
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 15 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/pages-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
- name: Install exiftool
run: sudo apt-get install exiftool ruby-mini-exiftool webp
- name: Install plugins
run: sudo gem install jekyll-webp jekyll-redirect-from
run: |
sudo apt-get install libjpeg-dev libpng-dev libtiff-dev libwebp-dev
sudo gem install webp-ffi jekyll-redirect-from
- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
Expand Down
9 changes: 1 addition & 8 deletions _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,4 @@ defaults:
values:
noheader: true

include: ["_*.JPG", "_*.jpg", "_*.webp"]
webp:
enabled: true
quality: 90
img_dir: ["/photos"]
nested: true
formats: [".JPG", ".jpg", ".jpeg"]
append_ext: true
include: ["_*.JPG", "_*.jpg", "_*.webp"]
16 changes: 10 additions & 6 deletions _plugins/photo_gen.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
require "mini_exiftool"
require "webp_ffi"

module Jekyll
class PhotoPageGenerator < Generator
Expand All @@ -25,14 +26,18 @@ def generate(site)

Dir.glob("#{photos_dir}/**/*").each do |photo|
next unless File.file?(photo)

puts photo
puts photo

file_extension = File.extname(photo)
filename = File.basename(photo, file_extension)
photo_path = File.dirname(photo).sub(photos_dir, '')
photo_url = "#{output_url}#{photo_path}"

dest = File.join(site.dest, photo_url)
FileUtils.mkdir_p dest
image_filename = File.join(photo_url, filename + file_extension)
preview_filename = File.join(photo_url, filename + '.webp')

begin
pic = MiniExiftool.new(photo)
pic.numerical = true
Expand All @@ -56,7 +61,8 @@ def generate(site)
'date' => capture_time,
'location' => location,
'camera' => camera,
'image' => File.join(photo_url, filename + file_extension),
'image' => image_filename,
'preview_image' => preview_filename,
'aperture' => aperture,
'sspeed' => sspeed,
'iso' => iso,
Expand All @@ -67,15 +73,13 @@ def generate(site)

photo_data.reject! { |p| p.empty? }

dest = File.join(site.dest, photo_url)
FileUtils.mkdir_p dest

photo_page = PageWithoutAFile.new(site, site.source, photo_url, "#{filename}.md")
photo_page.content = description
photo_page.data.merge!(photo_data)

site.pages << photo_page
FileUtils.cp(File.expand_path(photo), dest)
WebP.encode(File.expand_path(photo), File.join(dest, preview_filename), target_size: 524288)
rescue
puts "#{photo} didn't work"
end
Expand Down

0 comments on commit 02b1b43

Please sign in to comment.