Sha256: 1c18adef354ecd221a4d80e67f7b8f7dff93eaff9b968e40e70f841f16278683

Contents?: true

Size: 833 Bytes

Versions: 21

Compression:

Stored size: 833 Bytes

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class BandCampOnebox
      include Engine
      include StandardEmbed

      matches_regexp(/^https?:\/\/.*\.bandcamp\.com\/(album|track)\//)
      always_https
      requires_iframe_origins "https://bandcamp.com"

      def placeholder_html
        og = get_opengraph
        "<img src='#{og.image}' height='#{og.video_height}' #{og.title_attr}>"
      end

      def to_html
        og = get_opengraph
        escaped_src = og.video_secure_url || og.video

        <<-HTML
          <iframe src="#{escaped_src}"
                  width="#{og.video_width}"
                  height="#{og.video_height}"
                  scrolling="no"
                  frameborder="0"
                  allowfullscreen>
          </iframe>
        HTML
      end

    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
onebox-2.1.0 lib/onebox/engine/bandcamp_onebox.rb