class Jekyll::SeoTag::ImageDrop
A drop representing the page image The image path will be pulled from:
-
The ‘image` key if it’s a string
-
The ‘image.path` key if it’s a hash
-
The ‘image.facebook` key
-
The ‘image.twitter` key
Attributes
Public Class Methods
Source
# 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
Initialize a new ImageDrop
page - The page hash (e.g., Page#to_liquid) context - the Liquid::Context
Public Instance Methods
Source
# File lib/jekyll-seo-tag/image_drop.rb, line 30 def path @path ||= filters.uri_escape(absolute_url) if absolute_url end
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
Also aliased as: to_s
Private Instance Methods
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
Source
# File lib/jekyll-seo-tag/image_drop.rb, line 73 def filters @filters ||= Jekyll::SeoTag::Filters.new(context) end
Source
# 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
The normalized image hash with a ‘path` key (which may be nil)
Also aliased as: fallback_data
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