Module: Jekyll::Filters::Height

Defined in:
lib/jekyll/filters/height.rb

Overview

Obtain image height

Instance Method Summary collapse

Instance Method Details

#height(input) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/jekyll/filters/height.rb', line 7

def height(input)
  return unless input
  path = @context.registers[:site].in_source_dir input

  unless ::File.exist? path
    Jekyll.logger.warn "File doesn't exist #{input}"
    return input
  end

  Jekyll::Images::Cache.cached_image(path).height
rescue Vips::Error => e
  Jekyll.logger.warn "Failed to process #{input}: #{e.message}"
  nil
end