From 89bdf9b5351acaf439a22b70fd0aeaf54cb0fb96 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 27 Aug 2025 14:50:13 -0400 Subject: [PATCH 1/3] This is only used with statuses --- app/views/statuses/_og_image.html.haml | 4 ++-- app/views/statuses/show.html.haml | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/statuses/_og_image.html.haml b/app/views/statuses/_og_image.html.haml index 1ae97adff67..1f7f57f1562 100644 --- a/app/views/statuses/_og_image.html.haml +++ b/app/views/statuses/_og_image.html.haml @@ -1,6 +1,6 @@ -- if activity.is_a?(Status) && (activity.non_sensitive_with_media? || (activity.with_media? && Setting.preview_sensitive_media)) +- if status.non_sensitive_with_media? || (status.with_media? && Setting.preview_sensitive_media) - player_card = false - - activity.ordered_media_attachments.each do |media| + - status.ordered_media_attachments.each do |media| - if media.image? = opengraph 'og:image', full_asset_url(media.file.url(:original)) = opengraph 'og:image:type', media.file_content_type diff --git a/app/views/statuses/show.html.haml b/app/views/statuses/show.html.haml index cc779f4370e..679ce79da64 100644 --- a/app/views/statuses/show.html.haml +++ b/app/views/statuses/show.html.haml @@ -17,6 +17,6 @@ = opengraph 'profile:username', acct(@account)[1..] = render 'og_description', activity: @status - = render 'og_image', activity: @status, account: @account + = render 'og_image', status: @status, account: @account = render 'shared/web_app' From 1085b730e0705326b2d18c755f2bb6631eb9be4d Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 27 Aug 2025 15:19:03 -0400 Subject: [PATCH 2/3] Use `larger_media_format?` to determine player usage --- app/views/statuses/_og_image.html.haml | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/app/views/statuses/_og_image.html.haml b/app/views/statuses/_og_image.html.haml index 1f7f57f1562..075202d6ce4 100644 --- a/app/views/statuses/_og_image.html.haml +++ b/app/views/statuses/_og_image.html.haml @@ -1,5 +1,6 @@ +-# locals(status:, account:) + - if status.non_sensitive_with_media? || (status.with_media? && Setting.preview_sensitive_media) - - player_card = false - status.ordered_media_attachments.each do |media| - if media.image? = opengraph 'og:image', full_asset_url(media.file.url(:original)) @@ -10,7 +11,6 @@ - if media.description.present? = opengraph 'og:image:alt', media.description - elsif media.video? || media.gifv? - - player_card = true = opengraph 'og:image', full_asset_url(media.file.url(:small)) = opengraph 'og:image:type', 'image/png' - unless media.file.meta.nil? @@ -28,7 +28,6 @@ = opengraph 'twitter:player:width', media.file.meta.dig('original', 'width') = opengraph 'twitter:player:height', media.file.meta.dig('original', 'height') - elsif media.audio? - - player_card = true = opengraph 'og:image', full_asset_url(account.avatar.url(:original)) = opengraph 'og:image:width', '400' = opengraph 'og:image:height', '400' @@ -40,7 +39,7 @@ = opengraph 'twitter:player:stream:content_type', media.file_content_type = opengraph 'twitter:player:width', '670' = opengraph 'twitter:player:height', '380' - - if player_card + - if status.ordered_media_attachments.any?(&:larger_media_format?) = opengraph 'twitter:card', 'player' - else = opengraph 'twitter:card', 'summary_large_image' From a8d0b3f9ae22f9f1daefe40d5a663d111df8d2e5 Mon Sep 17 00:00:00 2001 From: Matt Jankowski Date: Wed, 27 Aug 2025 15:24:06 -0400 Subject: [PATCH 3/3] Description is also only used by status --- app/views/statuses/_og_description.html.haml | 2 +- app/views/statuses/show.html.haml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/statuses/_og_description.html.haml b/app/views/statuses/_og_description.html.haml index a7b18424d28..56aacbe9861 100644 --- a/app/views/statuses/_og_description.html.haml +++ b/app/views/statuses/_og_description.html.haml @@ -1,4 +1,4 @@ -- description = status_description(activity) +-# locals(description:) %meta{ name: 'description', content: description }/ = opengraph 'og:description', description diff --git a/app/views/statuses/show.html.haml b/app/views/statuses/show.html.haml index 679ce79da64..275931ec3f7 100644 --- a/app/views/statuses/show.html.haml +++ b/app/views/statuses/show.html.haml @@ -16,7 +16,7 @@ = opengraph 'og:locale', @status.language = opengraph 'profile:username', acct(@account)[1..] - = render 'og_description', activity: @status + = render 'og_description', description: status_description(@status) = render 'og_image', status: @status, account: @account = render 'shared/web_app'