Sha256: 397ff33f15880025d54026e4c3aa82b8cf1a25f6e36900eb4e8dc9373ec50e77
Contents?: true
Size: 625 Bytes
Versions: 1
Compression:
Stored size: 625 Bytes
Contents
AutoHtml.add_filter(:youtube).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil) do |text, options| regex = /(https?):\/\/(www.)?(youtube\.com\/watch\?v=|youtu\.be\/)([A-Za-z0-9_-]*)(\&\S+)?.*/ text.gsub(regex) do protocol = $1 youtube_id = $4 width = options[:width] height = options[:height] frameborder = options[:frameborder] wmode = options[:wmode] src = "#{protocol}://www.youtube.com/embed/#{youtube_id}" src += "?wmode=#{wmode}" if wmode %{<iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe>} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
auto_html-1.5.0 | lib/auto_html/filters/youtube.rb |