Fix #5360: Use OpenGraph's og:image metadata for posts.
* Add og:image:width, og:image:height, and og:image:type tags. * Use og:video tags for videos. * Use 720x720 instead of 150x150 preview images for videos. * Add duration tag to JSON-LD data for videos. * Add OpenGraph tags to media assets show page. * Respect Twitter max image size limits. * Don't include OpenGraph image tags when someone shares a plain https://danbooru.donmai.us link with no tag search. This caused random potentially NSFW images to be shown when someone shared a https://danbooru.donmai.us link on social media, which could be cached for long periods of time.
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
<% if policy(media_asset).can_see_image? %>
|
||||
<% if is_image? %>
|
||||
<%= tag.meta property: "og:image", content: image_url %>
|
||||
<%= tag.meta property: "og:image:secure_url", content: image_url %>
|
||||
<%= tag.meta property: "og:image:width", content: image_width %>
|
||||
<%= tag.meta property: "og:image:height", content: image_height %>
|
||||
<%= tag.meta property: "og:image:type", content: mime_type %>
|
||||
<% elsif is_video? || is_ugoira? %>
|
||||
<%= tag.meta property: "og:image", content: image_url %>
|
||||
<%= tag.meta property: "og:video", content: video_url %>
|
||||
<%= tag.meta property: "og:video:secure_url", content: video_url %>
|
||||
<%= tag.meta property: "og:video:width", content: image_width %>
|
||||
<%= tag.meta property: "og:video:height", content: image_height %>
|
||||
<%= tag.meta property: "og:video:type", content: mime_type %>
|
||||
|
||||
<%= json_ld_video_data %>
|
||||
<% end %>
|
||||
|
||||
<% if twitter_image_url.present? %>
|
||||
<%= tag.meta name: "twitter:card", content: "summary_large_image" %>
|
||||
<%= tag.meta name: "twitter:image", content: twitter_image_url %>
|
||||
<% end %>
|
||||
<% end %>
|
||||
Reference in New Issue
Block a user