Address #3415: og:image meta tags can point to video files.

This commit is contained in:
evazion
2017-12-06 09:01:13 -06:00
parent acd49be4cc
commit 131c0109d4
2 changed files with 10 additions and 2 deletions

View File

@@ -196,6 +196,14 @@ class Post < ApplicationRecord
"http://#{Danbooru.config.hostname}#{preview_file_url}"
end
def open_graph_image_url
if is_image? && has_large?
"http://#{Danbooru.config.hostname}#{large_file_url}"
else
complete_preview_file_url
end
end
def file_url_for(user)
if CurrentUser.mobile_mode?
large_file_url

View File

@@ -174,7 +174,7 @@
<meta property="og:title" content="<%= @post.presenter.humanized_essential_tag_string %> - <%= Danbooru.config.app_name %>">
<% if @post.visible? %>
<meta property="og:image" content="http://<%= Danbooru.config.hostname %><%= @post.large_file_url %>">
<meta property="og:image" content="<%= @post.open_graph_image_url %>">
<% end %>
<% if Danbooru.config.enable_post_search_counts %>
@@ -189,7 +189,7 @@
<meta name="twitter:description" content="<%= @post.presenter.humanized_tag_string %> - <%= Danbooru.config.app_name %>">
<% if @post.visible? %>
<meta name="twitter:image" content="http://<%= Danbooru.config.hostname %><%= @post.large_file_url %>">
<meta name="twitter:image" content="<%= @post.open_graph_image_url %>">
<% end %>
<% end %>