Class: Agave::Utils::MetaTags::Image
- Inherits:
-
Base
- Object
- Base
- Agave::Utils::MetaTags::Image
show all
- Defined in:
- lib/agave/utils/meta_tags/image.rb
Instance Attribute Summary
Attributes inherited from Base
#item, #site
Instance Method Summary
collapse
Methods inherited from Base
#card_tag, #content_tag, #initialize, #meta_tag, #og_tag, #seo_field_with_fallback, #tag
Instance Method Details
#build ⇒ Object
8
9
10
11
12
13
14
15
|
# File 'lib/agave/utils/meta_tags/image.rb', line 8
def build
return unless image
[
og_tag('og:image', image.url),
card_tag('twitter:image', image.url)
]
end
|
#image ⇒ Object
17
18
19
|
# File 'lib/agave/utils/meta_tags/image.rb', line 17
def image
@image ||= seo_field_with_fallback(:image, item_image)
end
|
#item_image ⇒ Object
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/agave/utils/meta_tags/image.rb', line 21
def item_image
item && item.fields
.select { |field| field.field_type == 'image' }
.map { |field| item.send(field.api_key) }
.compact
.find do |image|
image.width && image.height &&
image.width >= 200 && image.height >= 200
end
end
|