Sha256: d0f622cba9a3abe493473b0105ab2f4a25d9b5afa04cccbe81ceece70b363263

Contents?: true

Size: 1.14 KB

Versions: 34

Compression:

Stored size: 1.14 KB

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class VimeoOnebox
      include Engine
      include StandardEmbed

      # only match private Vimeo video links
      matches_regexp(/^https?:\/\/(www\.)?vimeo\.com\/\d+\/[^\/]+?$/)
      always_https

      WIDTH  ||= 640
      HEIGHT ||= 360

      def placeholder_html
        image_src = og_data.image_secure_url || og_data.image_url
        "<img src='#{image_src}' width='#{WIDTH}' height='#{HEIGHT}' #{og_data.title_attr}>"
      end

      def to_html
        video_src = og_data.video_secure_url || og_data.video_url
        if video_src.nil?
          id = uri.path[/\/(\d+)/, 1]
          video_src = "https://player.vimeo.com/video/#{id}"
        end
        video_src = video_src.gsub('autoplay=1', '').chomp("?")
        <<-HTML
          <iframe width="#{WIDTH}"
                  height="#{HEIGHT}"
                  src="#{video_src}"
                  data-original-href="#{link}"
                  frameborder="0"
                  allowfullscreen>
          </iframe>
        HTML
      end

      private

      def og_data
        @og_data = get_opengraph
      end
    end
  end
end

Version data entries

34 entries across 34 versions & 1 rubygems

Version Path
onebox-1.9.23 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.22 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.21 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.20 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.19 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.18 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.17 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.16 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.15 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.14 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.13 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.12 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.11 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.10 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.9 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.8 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.7 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.6 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.5 lib/onebox/engine/vimeo_onebox.rb
onebox-1.9.4 lib/onebox/engine/vimeo_onebox.rb