Sha256: 6dea93a413c07d4fdfda6fda2f586dbebd20b5a942a2273d0fb51da94ef0c6f7

Contents?: true

Size: 798 Bytes

Versions: 21

Compression:

Stored size: 798 Bytes

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class SketchFabOnebox
      include Engine
      include StandardEmbed

      matches_regexp(/^https?:\/\/sketchfab\.com\/(?:models\/|3d-models\/(?:[^\/\s]+-)?)([a-z0-9]{32})/)
      always_https
      requires_iframe_origins("https://sketchfab.com")

      def to_html
        og = get_opengraph
        src = og.video_url.gsub("autostart=1", "")

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

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

    end
  end
end

Version data entries

21 entries across 21 versions & 1 rubygems

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