Add condition to extra image generation to only operate on 'files' returned by the glob

This commit is contained in:
Christopher Peterson 2018-06-12 09:49:24 -04:00
parent 311f434ed7
commit aaaabbc2c0
1 changed files with 7 additions and 4 deletions

View File

@ -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