Sha256: ee8a7408b2cbbdb703daa2259f2b79acdcac47a0dca603344d2cc2252a9a3763

Contents?: true

Size: 628 Bytes

Versions: 2

Compression:

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

        escaped = url.gsub(/'/, "%27")
        "<a href='#{escaped}' target='_blank'><img src='#{escaped}'></a>"
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
onebox-1.6.5 lib/onebox/engine/image_onebox.rb
onebox-1.6.4 lib/onebox/engine/image_onebox.rb