mirror of
https://github.com/discourse/discourse.git
synced 2025-09-06 10:50:21 +08:00
UX: wrap full-size Twitter onebox images in aspect-ratio
This commit is contained in:
parent
62f09af1c2
commit
17584bca5e
2 changed files with 3 additions and 7 deletions
|
@ -16,20 +16,17 @@ class TwitterApi
|
|||
result = Rinku.auto_link(text, :all, 'target="_blank"').to_s
|
||||
|
||||
if tweet['extended_entities'] && media = tweet['extended_entities']['media']
|
||||
result << "<div class='tweet-images'>"
|
||||
media.each do |m|
|
||||
if m['type'] == 'photo'
|
||||
if large = m['sizes']['large']
|
||||
result << "<img class='tweet-image' src='#{m['media_url_https']}' width='#{large['w']}' height='#{large['h']}'>"
|
||||
result << "<div class='tweet-images'><img class='tweet-image' src='#{m['media_url_https']}' width='#{large['w']}' height='#{large['h']}'></div>"
|
||||
end
|
||||
elsif m['type'] == 'video'
|
||||
if large = m['sizes']['large']
|
||||
result << "<iframe class='tweet-video' src='https://twitter.com/i/videos/#{tweet['id_str']}' width='#{large['w']}' height='#{large['h']}' frameborder='0'></iframe>"
|
||||
result << "<div class='tweet-images'><iframe class='tweet-video' src='https://twitter.com/i/videos/#{tweet['id_str']}' width='#{large['w']}' height='#{large['h']}' frameborder='0'></iframe></div>"
|
||||
end
|
||||
end
|
||||
end
|
||||
result << "</div>"
|
||||
|
||||
end
|
||||
|
||||
result
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue