mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
FEATURE: Embed images in tweets with dimensions, if present
This commit is contained in:
parent
47720ba1ca
commit
c06a6a96cc
@ -135,6 +135,18 @@ aside.onebox {
|
|||||||
float: left;
|
float: left;
|
||||||
margin-right: 10px;
|
margin-right: 10px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.tweet-images {
|
||||||
|
display: block;
|
||||||
|
clear: both;
|
||||||
|
|
||||||
|
img.tweet-image {
|
||||||
|
margin-top: 1em;
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
float: none;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,7 +13,22 @@ class TwitterApi
|
|||||||
|
|
||||||
text = link_hashtags_in link_handles_in text
|
text = link_hashtags_in link_handles_in text
|
||||||
|
|
||||||
Rinku.auto_link(text, :all, 'target="_blank"').to_s
|
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']}'>"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
result << "</div>"
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
result
|
||||||
end
|
end
|
||||||
|
|
||||||
def user_timeline(screen_name)
|
def user_timeline(screen_name)
|
||||||
|
Loading…
Reference in New Issue
Block a user