From aaaabbc2c0f024c4b9f3f1fe69fe3cd17e0c40d2 Mon Sep 17 00:00:00 2001 From: Christopher Peterson <3893680+cspeterson@users.noreply.github.com> Date: Tue, 12 Jun 2018 09:49:24 -0400 Subject: [PATCH 1/2] Add condition to extra image generation to only operate on 'files' returned by the glob --- lib/jekyll-responsive-image/extra_image_generator.rb | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/lib/jekyll-responsive-image/extra_image_generator.rb b/lib/jekyll-responsive-image/extra_image_generator.rb index 5ea6c43..2ffd34b 100644 --- a/lib/jekyll-responsive-image/extra_image_generator.rb +++ b/lib/jekyll-responsive-image/extra_image_generator.rb @@ -2,6 +2,7 @@ module Jekyll module ResponsiveImage class ExtraImageGenerator < Jekyll::Generator include Jekyll::ResponsiveImage::Utils + include FileTest def generate(site) config = Config.new(site).to_h @@ -9,11 +10,13 @@ module Jekyll config['extra_images'].each do |pathspec| Dir.glob(site.in_source_dir(pathspec)) do |image_path| - path = Pathname.new(image_path) - relative_image_path = path.relative_path_from(site_source) + if FileTest.file?(image_path) + path = Pathname.new(image_path) + relative_image_path = path.relative_path_from(site_source) - result = ImageProcessor.process(relative_image_path, config) - result[:resized].each { |image| keep_resized_image!(site, image) } + result = ImageProcessor.process(relative_image_path, config) + result[:resized].each { |image| keep_resized_image!(site, image) } + end end end end From ac86fb24406c14bce84bc3714f0564b94c9d0949 Mon Sep 17 00:00:00 2001 From: Christopher Peterson <3893680+cspeterson@users.noreply.github.com> Date: Mon, 18 Jun 2018 12:37:24 -0400 Subject: [PATCH 2/2] Add feature test for recursive glob in extra-image generation --- features/extra-image-generation.feature | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/features/extra-image-generation.feature b/features/extra-image-generation.feature index 13c0952..1759186 100644 --- a/features/extra-image-generation.feature +++ b/features/extra-image-generation.feature @@ -15,6 +15,25 @@ Feature: Extra image generation And the file "_site/assets/resized/everybody-loves-jalapeño-pineapple-cornbread-100x50.png" should exist And the file "_site/assets/resized/progressive-100x50.jpeg" should exist + Scenario: Specifying a recursive glob pattern + Given I have a responsive_image configuration with: + """ + sizes: + - width: 100 + extra_images: + - assets/**/* + """ + And I have a file "index.html" with "Hello, world!" + When I run Jekyll + Then the image "assets/resized/everybody-loves-jalapeño-pineapple-cornbread-100x50.png" should have the dimensions "100x50" + And the image "assets/resized/exif-rotation-100x50.jpeg" should have the dimensions "100x50" + And the image "assets/resized/progressive-100x50.jpeg" should have the dimensions "100x50" + And the image "assets/resized/test-100x50.png" should have the dimensions "100x50" + And the file "_site/assets/resized/everybody-loves-jalapeño-pineapple-cornbread-100x50.png" should exist + And the file "_site/assets/resized/exif-rotation-100x50.jpeg" should exist + And the file "_site/assets/resized/progressive-100x50.jpeg" should exist + And the file "_site/assets/resized/test-100x50.png" should exist + Scenario: Honouring Jekyll 'source' configuration Given I have copied my site to "sub-dir/my-site-copy" And I have a configuration with: