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:
evazion
2022-12-02 00:59:23 -06:00
parent ca0a4af455
commit e11cd288b9
7 changed files with 100 additions and 50 deletions

View File

@@ -14,19 +14,6 @@ module SeoHelper
"#{Danbooru.config.canonical_app_name} is the original anime image booru. Search millions of anime pictures categorized by thousands of tags."
end
# https://developers.google.com/search/docs/data-types/video#video-object
def json_ld_video_data(post)
json_ld_tag({
"@context": "https://schema.org",
"@type": "VideoObject",
name: page_title,
description: meta_description,
uploadDate: post.created_at.iso8601,
thumbnailUrl: post.media_asset.variant("360x360").file_url,
contentUrl: post.file_url,
})
end
def json_ld_website_data
urls = [
Danbooru.config.twitter_url,