Module: ThumborHelpers::AlchemyOverrides::Picture

Defined in:
lib/thumbor_helpers/alchemy_overrides/picture.rb

Overview

Override Alchemy::Picture

Instance Method Summary collapse

Instance Method Details

#url(options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/thumbor_helpers/alchemy_overrides/picture.rb', line 7

def url(options = {})
  thumbor_disable = options.delete(:thumbor_disable) { false }
  url = super(options)

  if ThumborHelpers.config.enabled? and !thumbor_disable and url.match(ThumborHelpers.config.allowed_image_extensions)
    escaped = CGI.escape("#{ThumborHelpers.config.image_root_host}#{url}")
    encrypted_request = ThumborHelpers.config.cripto_generator.generate(image: escaped)
    "#{ThumborHelpers.config.server_url}#{encrypted_request}"
  else
    url
  end
end