Module: Jekyll::Filters::Width
- Defined in:
- lib/jekyll/filters/width.rb
Overview
Obtain image width
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.jekyll_site=(site) ⇒ Object
7 8 9 |
# File 'lib/jekyll/filters/width.rb', line 7 def self.jekyll_site=(site) @@jekyll_site = site end |
Instance Method Details
#jekyll_site ⇒ Object
11 12 13 |
# File 'lib/jekyll/filters/width.rb', line 11 def jekyll_site @@jekyll_site end |
#width(input) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
# File 'lib/jekyll/filters/width.rb', line 15 def width(input) return unless input path = jekyll_site.in_source_dir input unless ::File.exist? path Jekyll.logger.warn 'Width:', "#{input} doesn't exist" return input end Jekyll::Images::Cache.cached_image(path).width rescue Vips::Error => e Jekyll.logger.warn 'Width:', "Failed to process #{input}: #{e.message}" nil end |