This commit is contained in:
r888888888
2013-06-07 15:51:57 -07:00
parent 5791492b9b
commit 0b6cafbac0
2 changed files with 10 additions and 0 deletions

View File

@@ -153,6 +153,10 @@ class Post < ActiveRecord::Base
end
module ImageMethods
def twitter_card_supported?
file_size <= 1.megabyte && image_width.to_i >= 280 && image_height.to_ >= 150
end
def has_large?
is_image? && image_width.present? && image_width > Danbooru.config.large_image_width
end

View File

@@ -111,6 +111,12 @@
<meta property="og:title" content="<%= h @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">
<meta property="og:description" content="<%= h @post.presenter.humanized_tag_string %>">
<meta property="og:image" content="<%= @post.preview_file_url %>">
<!-- Twitter properties -->
<% if @post.twitter_card_supported? %>
<meta name="twitter:card" content="photo">
<meta name="twitter:image" content="<%= @post.file_url %>">
<% end %>
<% end %>
<%= render "posts/partials/common/secondary_links" %>