Skip to content

Commit

Permalink
[yufushiro] 複数枚の画像が添付された場合は先頭の画像のみをTwitter Cardに使用する
Browse files Browse the repository at this point in the history
  • Loading branch information
yufushiro committed Oct 11, 2023
1 parent 54b1a37 commit f052c12
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion app/views/statuses/_og_image.html.haml
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
- if activity.is_a?(Status) && (activity.non_sensitive_with_media? || (activity.with_media? && Setting.preview_sensitive_media))
- player_card = false
- activity.ordered_media_attachments.each do |media|
- activity.ordered_media_attachments.each_with_index do |media, index|
- if media.image?
= opengraph 'og:image', full_asset_url(media.file.url(:original))
= opengraph 'og:image:type', media.file_content_type
- if index == 0
= opengraph 'twitter:image', full_asset_url(media.file.url(:original))
- unless media.file.meta.nil?
= opengraph 'og:image:width', media.file.meta.dig('original', 'width')
= opengraph 'og:image:height', media.file.meta.dig('original', 'height')
- if media.description.present?
= opengraph 'og:image:alt', media.description
- if index == 0
= opengraph 'twitter:image:alt', media.description
- elsif media.video? || media.gifv?
- player_card = true
= opengraph 'og:image', full_asset_url(media.file.url(:small))
Expand Down

0 comments on commit f052c12

Please sign in to comment.