Sha256: 3960f20bad2c6996ea643826c8869c2a0c609b194ba597aa0d796f2adc9f1417

Contents?: true

Size: 675 Bytes

Versions: 3

Compression:

Stored size: 675 Bytes

Contents

# frozen_string_literal: true

module Onebox
  module Engine
    class WistiaOnebox
      include Engine
      include StandardEmbed

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

      def to_html
        get_oembed.html
      end

      def placeholder_html
        oembed = get_oembed
        return if Onebox::Helpers.blank?(oembed.thumbnail_url)
        "<img src='#{oembed.thumbnail_url}' #{oembed.title_attr}>"
      end

      private

      def get_oembed_url
        "https://fast.wistia.com/oembed?embedType=iframe&url=#{url}"
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
onebox-2.1.2 lib/onebox/engine/wistia_onebox.rb
onebox-2.1.1 lib/onebox/engine/wistia_onebox.rb
onebox-2.1.0 lib/onebox/engine/wistia_onebox.rb