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 30
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 62
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 73
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 ||= begin
    image_meta = page["image"]

    case image_meta
    when Hash
      { "path" => nil }.merge!(image_meta)
    when String
      { "path" => image_meta }
    else
      { "path" => nil }
    end
  end
end
Also aliased as: fallback_data
raw_path() click to toggle source
# File lib/jekyll-seo-tag/image_drop.rb, line 56
def raw_path
  @raw_path ||= begin
    image_hash["path"] || image_hash["facebook"] || image_hash["twitter"]
  end
end