Sha256: 0ec78e99702e0334b091de0c92a2655959d60abbc1fe1d82892707d012d824ea

Contents?: true

Size: 914 Bytes

Versions: 31

Compression:

Stored size: 914 Bytes

Contents

module Onebox
  module Engine
    class WistiaOnebox
      include Engine
      include StandardEmbed

      matches_regexp(/https?:\/\/(.+)?(wistia.com|wi.st)\/(medias|embed)\/.*/)
      always_https

      def to_html
        oembed_data[:html]
      end

      def placeholder_html
        return if Onebox::Helpers.blank?(oembed_data[:thumbnail_url])
        escaped_src = ::Onebox::Helpers.normalize_url_for_output(oembed_data[:thumbnail_url])
        "<img src='#{escaped_src}' #{Helpers.title_attr(oembed_data)}>"
      end

      private
        def oembed_data
          @oembed_data ||= begin
            oembed_url = "https://fast.wistia.com/oembed?embedType=iframe&url=#{url}"
            response = Onebox::Helpers.fetch_response(oembed_url) rescue "{}"
            Onebox::Helpers.symbolize_keys(::MultiJson.load(response))
          rescue
            {}
          end
        end
    end
  end
end

Version data entries

31 entries across 31 versions & 1 rubygems

Version Path
onebox-1.8.68 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.67 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.66 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.65 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.64 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.63 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.62 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.61 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.60 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.59 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.58 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.57 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.55 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.54 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.53 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.52 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.51 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.50 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.49 lib/onebox/engine/wistia_onebox.rb
onebox-1.8.48 lib/onebox/engine/wistia_onebox.rb