1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

[bug] sharing project or event w/o image on social network render error 500

This commit is contained in:
Sylvain 2016-10-11 16:07:34 +02:00
parent 7d54341d98
commit c500518c28
2 changed files with 28 additions and 12 deletions

View File

@ -1,5 +1,9 @@
<% image = @event.event_image.attachment.medium %>
<% width, height = image.dimensions %>
<%
if @event.event_image
image = @event.event_image.attachment.medium
width, height = image.dimensions
end
%>
<!DOCTYPE html>
<html lang="<%= I18n.locale %>">
@ -9,9 +13,11 @@
<!-- Facebook Open Graph -->
<meta property="og:title" content="<%= @event.title %>"/>
<meta property="og:description" content="<%= @event.description %>"/>
<meta property="og:image" content="<%= root_url+image.url %>"/>
<meta property="og:image:width" content="<%= width%>" />
<meta property="og:image:height" content="<%=height%>" />
<% if @event.event_image %>
<meta property="og:image" content="<%= root_url+image.url %>"/>
<meta property="og:image:width" content="<%= width%>" />
<meta property="og:image:height" content="<%=height%>" />
<% end %>
<meta property="fb:app_id" content="<%= Rails.application.secrets.facebook_app_id%>" />
<meta property="og:url" content="<%= root_url+'#!/events/'+@event.id.to_s %>" />
@ -20,7 +26,9 @@
<meta name="twitter:site" content="<%= ENV['TWITTER_NAME'] %>">
<meta name="twitter:title" content="<%= @event.title %>">
<meta name="twitter:description" content="<%= @event.description %>">
<meta name="twitter:image" content="<%= root_url+image.url %>">
<% if @event.event_image %>
<meta name="twitter:image" content="<%= root_url+image.url %>">
<% end %>
</head>
</html>

View File

@ -1,5 +1,9 @@
<% image = @project.project_image.attachment.medium %>
<% width, height = image.dimensions %>
<%
if @project.project_image
image = @project.project_image.attachment.medium
width, height = image.dimensions
end
%>
<!DOCTYPE html>
<html lang="<%= I18n.locale %>">
@ -9,9 +13,11 @@
<!-- Facebook Open Graph -->
<meta property="og:title" content="<%= @project.name %>"/>
<meta property="og:description" content="<%= strip_tags(@project.description) %>"/>
<meta property="og:image" content="<%= root_url+image.url %>"/>
<meta property="og:image:width" content="<%= width%>" />
<meta property="og:image:height" content="<%=height%>" />
<% if @project.project_image %>
<meta property="og:image" content="<%= root_url+image.url %>"/>
<meta property="og:image:width" content="<%= width%>" />
<meta property="og:image:height" content="<%=height%>" />
<% end %>
<meta property="fb:app_id" content="<%= Rails.application.secrets.facebook_app_id%>" />
<meta property="og:url" content="<%= root_url+'#!/projects/'+@project.slug %>" />
@ -20,7 +26,9 @@
<meta name="twitter:site" content="<%= ENV['TWITTER_NAME'] %>">
<meta name="twitter:title" content="<%= @project.name %>">
<meta name="twitter:description" content="<%= strip_tags(@project.description) %>">
<meta name="twitter:image" content="<%= root_url+image.url %>">
<% if @project.project_image %>
<meta name="twitter:image" content="<%= root_url+image.url %>">
<% end %>
</head>
</html>