Sha256: 1cdd6c5eb1915647eb45447a6f1dd20a52ff1455d63066062afc143aa9273471

Contents?: true

Size: 779 Bytes

Versions: 7

Compression:

Stored size: 779 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

7 entries across 7 versions & 1 rubygems

Version Path
onebox-2.2.19 lib/onebox/engine/sketchfab_onebox.rb
onebox-2.2.18 lib/onebox/engine/sketchfab_onebox.rb
onebox-2.2.17 lib/onebox/engine/sketchfab_onebox.rb
onebox-2.2.16 lib/onebox/engine/sketchfab_onebox.rb
onebox-2.2.15 lib/onebox/engine/sketchfab_onebox.rb
onebox-2.2.14 lib/onebox/engine/sketchfab_onebox.rb
onebox-2.2.13 lib/onebox/engine/sketchfab_onebox.rb