class Jekyll::SeoTag::ImageDrop

A drop representing the page image The image path will be pulled from:

  1. The `image` key if it's a string

  2. The `image.path` key if it's a hash

  3. The `image.facebook` key

  4. The `image.twitter` key

Attributes

context[RW]
page[RW]

Public Class Methods

new(page: nil, context: nil) click to toggle source

Initialize a new ImageDrop

page - The page hash (e.g., Page#to_liquid) context - the Liquid::Context

# File lib/jekyll-seo-tag/image_drop.rb, line 19
def initialize(page: nil, context: nil)
  raise ArgumentError unless page && context
  @mutations = {}
  @page = page
  @context = context
end

Public Instance Methods

path() click to toggle source

Called path for backwards compatability, this is really the escaped, absolute URL representing the page's image Returns nil if no image path can be determined

# File lib/jekyll-seo-tag/image_drop.rb, line 29
def path
  @path ||= filters.uri_escape(absolute_url) if absolute_url
end
Also aliased as: to_s
to_s()
Alias for: path

Private Instance Methods

absolute_url() click to toggle source
# File lib/jekyll-seo-tag/image_drop.rb, line 57
def absolute_url
  return unless raw_path
  return @absolute_url if defined? @absolute_url
  @absolute_url = if raw_path.is_a?(String) && absolute_url?(raw_path) == false
                    filters.absolute_url raw_path
                  else
                    raw_path
                  end
end
fallback_data()
Alias for: image_hash
filters() click to toggle source
# File lib/jekyll-seo-tag/image_drop.rb, line 67
def filters
  @filters ||= Jekyll::SeoTag::Filters.new(context)
end
image_hash() click to toggle source

The normalized image hash with a `path` key (which may be nil)

# File lib/jekyll-seo-tag/image_drop.rb, line 40
def image_hash
  @image_hash ||= if page["image"].is_a?(Hash)
                    { "path" => nil }.merge(page["image"])
                  elsif page["image"].is_a?(String)
                    { "path" => page["image"] }
                  else
                    { "path" => nil }
                  end
end
Also aliased as: fallback_data
raw_path() click to toggle source
# File lib/jekyll-seo-tag/image_drop.rb, line 51
def raw_path
  @raw_path ||= begin
    image_hash["path"] || image_hash["facebook"] || image_hash["twitter"]
  end
end