include default image for FB for timeline

This commit is contained in:
danielgrippi 2012-05-03 17:37:48 -07:00
parent 35b0f7637b
commit 5118985aeb

View file

@ -12,7 +12,8 @@ module OpenGraphHelper
end
def og_image(post)
tags = post.photos.map{|x| meta_tag_with_property('og:image', x.url(:thumb_large))} || []
tags = post.photos.map{|x| meta_tag_with_property('og:image', x.url(:thumb_large))}
tags << meta_tag_with_property('og:image', default_image_url) if tags.empty?
tags.join(' ')
end
@ -38,4 +39,15 @@ module OpenGraphHelper
def meta_tag_with_property(name, content)
content_tag(:meta, '', :property => name, :content => content)
end
private
# This method compensates for hosting assets off of s3
def default_image_url
if image_path('asterisk.png').include?("http")
image_path('asterisk.png')
else
"#{root_url.chop}#{image_path('asterisk.png')}"
end
end
end