Skip to content

Commit

Permalink
Use fragment for width/height since adding any querystring gives you …
Browse files Browse the repository at this point in the history
…404.
  • Loading branch information
stefansundin committed Oct 11, 2017
1 parent 5bf0685 commit a6b0e07
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
3 changes: 2 additions & 1 deletion config/initializers/05-string.rb
Expand Up @@ -257,7 +257,8 @@ def embed_html(request=nil)
elsif %r{^https?://video\.twimg\.com/.+/(?<width>\d+)x(?<height>\d+)/.+\.mp4}i =~ self
"<iframe width='#{width}' height='#{height}' src='#{self}' frameborder='0' scrolling='no' allowfullscreen referrerpolicy='no-referrer'></iframe>"
elsif %r{^https?://[a-z0-9\-._~:/?#\[\]@!$&'()*+,;=]+\.mp4}i =~ self
query = CGI.parse(URI.parse(self).query || "")
uri = URI.parse(self)
query = CGI.parse(uri.query || "").merge(CGI.parse(uri.fragment || "")) { |key,oldval,newval| oldval + newval }
width = query["w"][0] || "640"
height = query["h"][0] || "538"
"<iframe width='#{width}' height='#{height}' src='#{self}' frameborder='0' scrolling='no' allowfullscreen referrerpolicy='no-referrer'></iframe>"
Expand Down
2 changes: 1 addition & 1 deletion views/twitter_feed.erb
Expand Up @@ -34,7 +34,7 @@
text += " #{video["url"]}"
else
# no dimension information in the URL, so add some (i.e. /tweet_video/)
text += " #{video["url"]}?w=#{entity["sizes"]["large"]["w"]}&h=#{entity["sizes"]["large"]["h"]}"
text += " #{video["url"]}#w=#{entity["sizes"]["large"]["w"]}&h=#{entity["sizes"]["large"]["h"]}"
end
end
end
Expand Down

0 comments on commit a6b0e07

Please sign in to comment.