mirror of
https://github.com/discourse/discourse.git
synced 2025-06-03 02:48:28 +08:00
FIX: Don’t use user_generated
images as avatar images in Oneboxed Twitter content (#13712)
By default, Twitter will return the URL for the avatar image of the tweet poster as the `og:image` value. However, if the `user_generated` attribute is true, we should not use this as the avatar URL as this will be an URL of an image in the tweet itself (e.g., an image belonging to a tweeted news story).
This commit is contained in:
@ -23,7 +23,7 @@ module Onebox
|
||||
html.css('meta').each do |m|
|
||||
if m.attribute('property') && m.attribute('property').to_s.match(/^og:/i)
|
||||
m_content = m.attribute('content').to_s.strip
|
||||
m_property = m.attribute('property').to_s.gsub('og:', '')
|
||||
m_property = m.attribute('property').to_s.gsub('og:', '').gsub(':', '_')
|
||||
twitter_data[m_property.to_sym] = m_content
|
||||
end
|
||||
end
|
||||
@ -100,7 +100,7 @@ module Onebox
|
||||
if twitter_api_credentials_present?
|
||||
access(:user, :profile_image_url_https).sub('normal', '400x400')
|
||||
elsif twitter_data[:image]
|
||||
twitter_data[:image]
|
||||
twitter_data[:image] unless twitter_data[:image_user_generated]
|
||||
end
|
||||
end
|
||||
|
||||
|
Reference in New Issue
Block a user