闭社主体 forked from https://github.com/tootsuite/mastodon
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

38 lines
2.1 KiB

  1. - if activity.is_a?(Status) && (activity.non_sensitive_with_media? || (activity.with_media? && Setting.preview_sensitive_media))
  2. - player_card = false
  3. - activity.media_attachments.each do |media|
  4. - if media.image?
  5. = opengraph 'og:image', full_asset_url(media.file.url(:original))
  6. = opengraph 'og:image:type', media.file_content_type
  7. - unless media.file.meta.nil?
  8. = opengraph 'og:image:width', media.file.meta.dig('original', 'width')
  9. = opengraph 'og:image:height', media.file.meta.dig('original', 'height')
  10. - if media.description.present?
  11. = opengraph 'og:image:alt', media.description
  12. - elsif media.video? || media.gifv?
  13. - player_card = true
  14. = opengraph 'og:image', full_asset_url(media.file.url(:small))
  15. = opengraph 'og:image:type', 'image/png'
  16. - unless media.file.meta.nil?
  17. = opengraph 'og:image:width', media.file.meta.dig('small', 'width')
  18. = opengraph 'og:image:height', media.file.meta.dig('small', 'height')
  19. = opengraph 'og:video', full_asset_url(media.file.url(:original))
  20. = opengraph 'og:video:secure_url', full_asset_url(media.file.url(:original))
  21. = opengraph 'og:video:type', media.file_content_type
  22. = opengraph 'twitter:player', medium_player_url(media)
  23. = opengraph 'twitter:player:stream', full_asset_url(media.file.url(:original))
  24. = opengraph 'twitter:player:stream:content_type', media.file_content_type
  25. - unless media.file.meta.nil?
  26. = opengraph 'og:video:width', media.file.meta.dig('original', 'width')
  27. = opengraph 'og:video:height', media.file.meta.dig('original', 'height')
  28. = opengraph 'twitter:player:width', media.file.meta.dig('original', 'width')
  29. = opengraph 'twitter:player:height', media.file.meta.dig('original', 'height')
  30. - if player_card
  31. = opengraph 'twitter:card', 'player'
  32. - else
  33. = opengraph 'twitter:card', 'summary_large_image'
  34. - else
  35. = opengraph 'og:image', full_asset_url(account.avatar.url(:original))
  36. = opengraph 'og:image:width', '120'
  37. = opengraph 'og:image:height','120'
  38. = opengraph 'twitter:card', 'summary'