Module: Shi::Jekyll::Images::SEO

Extended by:
Config
Defined in:
lib/shi/jekyll/images/seo.rb

Class Method Summary collapse

Methods included from Config

config, get_value, path_by_page, site, site_config

Class Method Details

.file_by_path(path) ⇒ Object



11
12
13
14
# File 'lib/shi/jekyll/images/seo.rb', line 11

def file_by_path path
  path_with_leading_slash = Jekyll::PathManager::join '', path
  site.static_files.find { |f| f.relative_path == path || f.relative_path == path_with_leading_slash }
end

.process_page(page) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
28
# File 'lib/shi/jekyll/images/seo.rb', line 16

def process_page page
  image = page.data['image']
  if image
    file = file_by_path image
    if file
      return nil if file.write?
      bounds = get_value(page, 'seo_image_bounds') || '640x640'
      crop = get_value(page, 'seo_image_crop') || '500:261+0+0'
      result = Shi::Jekyll::Images::WebPFile::create page, file, bounds, crop
      page.data['image'] = result.url
    end
  end
end