Skip to content
Browse files

Add image for open graph protocol in facebook

  • Loading branch information...
1 parent 4641aef commit 2796d76458ddf6fbc59248053f33697805a87fa8 @msevestre msevestre committed
Showing with 9 additions and 1 deletion.
  1. +1 −0 .gitignore
  2. +5 −1 app/helpers/spree/social_helper.rb
  3. +3 −0 app/views/spree/social/_facebook.html.erb
View
1 .gitignore
@@ -8,3 +8,4 @@ tmp
nbproject
*.swp
spec/dummy
+.rvmrc
View
6 app/helpers/spree/social_helper.rb
@@ -4,7 +4,7 @@ def pin_it_button(product)
return if product.images.empty?
url = escape spree.product_url(product)
- media = escape absolute_image_url(product.images.first.attachment.url)
+ media = absolute_product_image(product.images.first)
description = escape product.name
link_to("Pin It",
@@ -13,6 +13,10 @@ def pin_it_button(product)
"count-layout" => "none").html_safe
end
+ def absolute_product_image(image)
+ escape absolute_image_url(image.attachment.url)
+ end
+
private
def escape(string)
View
3 app/views/spree/social/_facebook.html.erb
@@ -4,6 +4,9 @@
<meta property="og:type" content="product" />
<meta property="og:url" content="<%= product_url(@product) %>" />
<meta property="og:description" content="<%= @product.description %>" />
+ <% @product.images.each do |img| %>
+ <meta property="og:image" content="<%= absolute_product_image(img) %>" />
+ <% end %>
<meta property="fb:app_id" content="<%= Spree::Config.facebook_app_id %>" />
<% end %>

0 comments on commit 2796d76

Please sign in to comment.
Something went wrong with that request. Please try again.