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:
@@ -167,18 +167,6 @@ class Post < ApplicationRecord
|
||||
media_asset.variant(:preview).file_url
|
||||
end
|
||||
|
||||
def open_graph_image_url
|
||||
if is_image?
|
||||
if has_large?
|
||||
large_file_url
|
||||
else
|
||||
file_url
|
||||
end
|
||||
else
|
||||
preview_file_url
|
||||
end
|
||||
end
|
||||
|
||||
def file_url_for(user)
|
||||
if user.default_image_size == "large" && image_width > Danbooru.config.large_image_width
|
||||
tagged_large_file_url
|
||||
@@ -209,10 +197,6 @@ class Post < ApplicationRecord
|
||||
end
|
||||
|
||||
concerning :ImageMethods do
|
||||
def twitter_card_supported?
|
||||
image_width.to_i >= 280 && image_height.to_i >= 150
|
||||
end
|
||||
|
||||
def has_large?
|
||||
return false if has_tag?("animated_gif") || has_tag?("animated_png")
|
||||
return true if is_ugoira?
|
||||
|
||||
Reference in New Issue
Block a user