Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

support width, height for youtube

  • Loading branch information...
commit b28c992602e566ca6664cc4cc6bdd73cad51dfbb 1 parent a656e53
@stereobooster authored
Showing with 12 additions and 2 deletions.
  1. +12 −2 _plugins/jekyll_oembed.rb
View
14 _plugins/jekyll_oembed.rb
@@ -1,4 +1,4 @@
-# jekyll_oembed 0.0.2
+# jekyll_oembed 0.0.3
# https://github.com/stereobooster/jekyll_oembed
begin
@@ -23,8 +23,18 @@ def render(context)
params = Hash[*params.map{|val| val.split('=')}.flatten]
resource = OEmbed::Providers.get(url, params)
+ html = resource.html
+
+ if url =~ /:\/\/(www.youtube.com|youtu.be)\//
+ %w{width height}.each do |name|
+ if params[name]
+ html.gsub! Regexp.new(name+'="\\d+'), name+'="'+params[name]
+ end
+ end
+ end
+
# resource.video?, resource.thumbnail_url
- "<div class='oembed #{resource.type}'>#{resource.html}</div>"
+ "<div class='oembed #{resource.type}'>#{html}</div>"
rescue OEmbed::NotFound
warn "No embeddable content at #{url}"
"<a href='#{url}'>#{url}</a>"
Please sign in to comment.
Something went wrong with that request. Please try again.