2016-06-06 07:32:13 +10:00
|
|
|
module Jekyll
|
2016-09-28 04:59:24 +10:00
|
|
|
module ResponsiveImage
|
2016-06-06 07:32:13 +10:00
|
|
|
class ExtraImageGenerator < Jekyll::Generator
|
2016-09-28 04:59:24 +10:00
|
|
|
include Jekyll::ResponsiveImage::Utils
|
2016-06-06 07:32:13 +10:00
|
|
|
|
|
|
|
def generate(site)
|
2016-09-28 08:49:18 +10:00
|
|
|
config = Config.new(site).to_h
|
2016-10-12 07:21:11 +11:00
|
|
|
site_source = Pathname.new(site.source)
|
2016-06-06 07:32:13 +10:00
|
|
|
|
|
|
|
config['extra_images'].each do |pathspec|
|
2016-09-26 06:37:10 +10:00
|
|
|
Dir.glob(site.in_source_dir(pathspec)) do |image_path|
|
2016-10-12 07:21:11 +11:00
|
|
|
path = Pathname.new(image_path)
|
|
|
|
relative_image_path = path.relative_path_from(site_source)
|
2016-09-26 06:37:10 +10:00
|
|
|
|
2016-10-12 07:21:11 +11:00
|
|
|
result = ImageProcessor.process(relative_image_path, config)
|
2016-09-26 05:23:06 +10:00
|
|
|
result[:resized].each { |image| keep_resized_image!(site, image) }
|
|
|
|
end
|
2016-06-06 07:32:13 +10:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|