FEATURE: Embed images in tweets with dimensions, if present

This commit is contained in:
Robin Ward 2016-05-11 16:11:26 -04:00
parent 47720ba1ca
commit c06a6a96cc
No known key found for this signature in database
GPG Key ID: 0E091E2B4ED1B83D
2 changed files with 28 additions and 1 deletions

View File

@ -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;
}
}
}
}

View File

@ -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)