Sha256: 2e435d9ea9930a6df641eea5462ada2fb2ea471f821cd96426479b99ea0af3ab

Contents?: true

Size: 935 Bytes

Versions: 2

Compression:

Stored size: 935 Bytes

Contents

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

      def to_html
        opengraph = get_opengraph

        src = opengraph[:video_url].gsub("autostart=1", "")
        escaped_src = ::Onebox::Helpers.normalize_url_for_output(src)

        <<-HTML
          <iframe src="#{escaped_src}"
                  width="#{opengraph[:video_width]}"
                  height="#{opengraph[:video_height]}"
                  scrolling="no"
                  frameborder="0"
                  allowfullscreen>
          </iframe>
        HTML
      end

      def placeholder_html
        opengraph = get_opengraph
        escaped_src = ::Onebox::Helpers.normalize_url_for_output(opengraph[:image])
        "<img src='#{escaped_src}'>"
      end

    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
onebox-1.8.79 lib/onebox/engine/sketchfab_onebox.rb
onebox-1.8.78 lib/onebox/engine/sketchfab_onebox.rb