Merge pull request #71 from decipher-media/master
Add condition to extra image generation to only operate on 'files' re…
This commit is contained in:
commit
7a3dbf1ab9
|
@ -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/everybody-loves-jalapeño-pineapple-cornbread-100x50.png" should exist
|
||||||
And the file "_site/assets/resized/progressive-100x50.jpeg" 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
|
Scenario: Honouring Jekyll 'source' configuration
|
||||||
Given I have copied my site to "sub-dir/my-site-copy"
|
Given I have copied my site to "sub-dir/my-site-copy"
|
||||||
And I have a configuration with:
|
And I have a configuration with:
|
||||||
|
|
|
@ -2,6 +2,7 @@ module Jekyll
|
||||||
module ResponsiveImage
|
module ResponsiveImage
|
||||||
class ExtraImageGenerator < Jekyll::Generator
|
class ExtraImageGenerator < Jekyll::Generator
|
||||||
include Jekyll::ResponsiveImage::Utils
|
include Jekyll::ResponsiveImage::Utils
|
||||||
|
include FileTest
|
||||||
|
|
||||||
def generate(site)
|
def generate(site)
|
||||||
config = Config.new(site).to_h
|
config = Config.new(site).to_h
|
||||||
|
@ -9,11 +10,13 @@ module Jekyll
|
||||||
|
|
||||||
config['extra_images'].each do |pathspec|
|
config['extra_images'].each do |pathspec|
|
||||||
Dir.glob(site.in_source_dir(pathspec)) do |image_path|
|
Dir.glob(site.in_source_dir(pathspec)) do |image_path|
|
||||||
path = Pathname.new(image_path)
|
if FileTest.file?(image_path)
|
||||||
relative_image_path = path.relative_path_from(site_source)
|
path = Pathname.new(image_path)
|
||||||
|
relative_image_path = path.relative_path_from(site_source)
|
||||||
|
|
||||||
result = ImageProcessor.process(relative_image_path, config)
|
result = ImageProcessor.process(relative_image_path, config)
|
||||||
result[:resized].each { |image| keep_resized_image!(site, image) }
|
result[:resized].each { |image| keep_resized_image!(site, image) }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue