Sha256: ea7edb2010305d7ba56b1fe7a1ab87c265d5ca5b22af87031f6c4d66aa4378ea

Contents?: true

Size: 583 Bytes

Versions: 38

Compression:

Stored size: 583 Bytes

Contents

module Onebox
  module Engine
    class ImageOnebox
      include Engine

      matches_regexp /^(https?:)?\/\/.+\.(png|jpg|jpeg|gif|bmp|tif|tiff)(\?.*)?$/i

      def always_https?
        WhitelistedGenericOnebox.host_matches(uri, WhitelistedGenericOnebox.https_hosts)
      end

      def to_html
        # Fix Dropbox image links
        if /^https:\/\/www.dropbox.com\/s\//.match @url
          @url.gsub!("https://www.dropbox.com","https://dl.dropboxusercontent.com")
        end

        "<a href='#{@url}' target='_blank'><img src='#{@url}'></a>"
      end
    end
  end
end

Version data entries

38 entries across 38 versions & 1 rubygems

Version Path
onebox-1.5.39 lib/onebox/engine/image_onebox.rb
onebox-1.5.38 lib/onebox/engine/image_onebox.rb
onebox-1.5.37 lib/onebox/engine/image_onebox.rb
onebox-1.5.36 lib/onebox/engine/image_onebox.rb
onebox-1.5.35 lib/onebox/engine/image_onebox.rb
onebox-1.5.34 lib/onebox/engine/image_onebox.rb
onebox-1.5.33 lib/onebox/engine/image_onebox.rb
onebox-1.5.32 lib/onebox/engine/image_onebox.rb
onebox-1.5.31 lib/onebox/engine/image_onebox.rb
onebox-1.5.30 lib/onebox/engine/image_onebox.rb
onebox-1.5.29 lib/onebox/engine/image_onebox.rb
onebox-1.5.28 lib/onebox/engine/image_onebox.rb
onebox-1.5.27 lib/onebox/engine/image_onebox.rb
onebox-1.5.26 lib/onebox/engine/image_onebox.rb
onebox-1.5.25 lib/onebox/engine/image_onebox.rb
onebox-1.5.24 lib/onebox/engine/image_onebox.rb
onebox-1.5.23 lib/onebox/engine/image_onebox.rb
onebox-1.5.22 lib/onebox/engine/image_onebox.rb