Sha256: bf721c8155e10c5da0e087cede6b4ce31ed4d82f97b8605976a996c6e1ea2b49
Contents?: true
Size: 628 Bytes
Versions: 2
Compression:
Stored size: 628 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+)?(\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
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
auto_html-1.5.1.1 | lib/auto_html/filters/youtube.rb |
auto_html-1.5.1 | lib/auto_html/filters/youtube.rb |