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;
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
def user_timeline(screen_name)
|
||||
|
|
Loading…
Reference in New Issue