1
0

_og_image.html.haml 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. - elsif media.audio?
  31. - player_card = true
  32. = opengraph 'og:image', full_asset_url(account.avatar.url(:original))
  33. = opengraph 'og:image:width', '400'
  34. = opengraph 'og:image:height','400'
  35. = opengraph 'og:audio', full_asset_url(media.file.url(:original))
  36. = opengraph 'og:audio:secure_url', full_asset_url(media.file.url(:original))
  37. = opengraph 'og:audio:type', media.file_content_type
  38. = opengraph 'twitter:player', medium_player_url(media)
  39. = opengraph 'twitter:player:stream', full_asset_url(media.file.url(:original))
  40. = opengraph 'twitter:player:stream:content_type', media.file_content_type
  41. = opengraph 'twitter:player:width', '670'
  42. = opengraph 'twitter:player:height', '380'
  43. - if player_card
  44. = opengraph 'twitter:card', 'player'
  45. - else
  46. = opengraph 'twitter:card', 'summary_large_image'
  47. - else
  48. = opengraph 'og:image', full_asset_url(account.avatar.url(:original))
  49. = opengraph 'og:image:width', '400'
  50. = opengraph 'og:image:height','400'
  51. = opengraph 'twitter:card', 'summary'