Sha256: 10df72596af6743994c3a84c96477b40dc1113d4f89cb6b1f4b868af65bcbf30
Contents?: true
Size: 951 Bytes
Versions: 3
Compression:
Stored size: 951 Bytes
Contents
AutoHtml.add_filter(:youtube).with(:width => 420, :height => 315, :frameborder => 0, :wmode => nil, :autoplay => false, :hide_related => false) do |text, options| regex = /(https?:\/\/)?(www.)?(youtube\.com\/watch\?v=|youtu\.be\/|youtube\.com\/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(\&\S+)?(\?\S+)?/ text.gsub(regex) do youtube_id = $4 width = options[:width] height = options[:height] frameborder = options[:frameborder] wmode = options[:wmode] autoplay = options[:autoplay] hide_related = options[:hide_related] src = "//www.youtube.com/embed/#{youtube_id}" params = [] params << "wmode=#{wmode}" if wmode params << "autoplay=1" if autoplay params << "rel=0" if hide_related src += "?#{params.join '&'}" unless params.empty? %{<div class="video youtube"><iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe></div>} end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
auto_html-1.6.4 | lib/auto_html/filters/youtube.rb |
auto_html-1.6.3 | lib/auto_html/filters/youtube.rb |
auto_html-1.6.2 | lib/auto_html/filters/youtube.rb |