diff --git a/app/models/post.rb b/app/models/post.rb index 72bab1ae9..bb72b21e3 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -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 diff --git a/app/views/posts/show.html.erb b/app/views/posts/show.html.erb index 2c1fc4de9..57d8d51ad 100644 --- a/app/views/posts/show.html.erb +++ b/app/views/posts/show.html.erb @@ -111,6 +111,12 @@ + + + <% if @post.twitter_card_supported? %> + + + <% end %> <% end %> <%= render "posts/partials/common/secondary_links" %>