Class: Imgproxy::UrlAdapters::Shrine

Inherits:
Object
  • Object
show all
Defined in:
lib/imgproxy/url_adapters/shrine.rb

Overview

Adapter for Shrine

Imgproxy.configure do |config|
  config.url_adapters.add Imgproxy::UrlAdapters::Shrine.new
end

Imgproxy.url_for(user.avatar)

Instance Method Summary collapse

Instance Method Details

#applicable?(image) ⇒ Boolean

Returns:

  • (Boolean)


13
14
15
# File 'lib/imgproxy/url_adapters/shrine.rb', line 13

def applicable?(image)
  image.is_a?(::Shrine::UploadedFile)
end

#url(image) ⇒ Object



17
18
19
20
21
22
23
# File 'lib/imgproxy/url_adapters/shrine.rb', line 17

def url(image)
  return s3_url(image) if use_s3_url(image)

  opts = {}
  opts[:host] = config.shrine_host if config.shrine_host
  image.url(**opts)
end