Sha256: b65d2261c9f78c6b8b6c25fbf9ec4a5097dc1fe8f1c6d252c7f517ca12834e3e
Contents?: true
Size: 961 Bytes
Versions: 1
Compression:
Stored size: 961 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-container youtube"><iframe width="#{width}" height="#{height}" src="#{src}" frameborder="#{frameborder}" allowfullscreen></iframe></div>} end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
auto_html-whistlerbrk-2.0.0.pre | lib/auto_html/filters/youtube.rb |