Class: Imgproxy::Config

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

Overview

Imgproxy config

See Also:

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfig

Returns a new instance of Config.



24
25
26
27
28
# File 'lib/imgproxy/config.rb', line 24

def initialize
  self.signature_size = 32
  self.use_short_options = true
  self.base64_encode_urls = false
end

Instance Attribute Details

#base64_encode_urlsBoolean

Returns base64 encode the URL Defaults to false.

Returns:

  • (Boolean)

    base64 encode the URL Defaults to false



22
23
24
# File 'lib/imgproxy/config.rb', line 22

def base64_encode_urls
  @base64_encode_urls
end

#endpointString

Returns imgproxy endpoint.

Returns:

  • (String)

    imgproxy endpoint



8
9
10
# File 'lib/imgproxy/config.rb', line 8

def endpoint
  @endpoint
end

#keyString

Returns imgproxy signature key.

Returns:

  • (String)

    imgproxy signature key



10
11
12
# File 'lib/imgproxy/config.rb', line 10

def key
  @key
end

#saltString

Returns imgproxy signature salt.

Returns:

  • (String)

    imgproxy signature salt



12
13
14
# File 'lib/imgproxy/config.rb', line 12

def salt
  @salt
end

#signature_sizeInteger

Returns imgproxy signature size. Defaults to 32.

Returns:

  • (Integer)

    imgproxy signature size. Defaults to 32



14
15
16
# File 'lib/imgproxy/config.rb', line 14

def signature_size
  @signature_size
end

#use_short_optionsBoolean

Returns use short processing option names (rs for resize, g for gravity, etc). Defaults to true.

Returns:

  • (Boolean)

    use short processing option names (rs for resize, g for gravity, etc). Defaults to true



18
19
20
# File 'lib/imgproxy/config.rb', line 18

def use_short_options
  @use_short_options
end

Instance Method Details

#hex_key=(value) ⇒ Object

Decodes hex-encoded key and sets it to #key

Parameters:

  • value (String)

    hex-encoded signature key



33
34
35
# File 'lib/imgproxy/config.rb', line 33

def hex_key=(value)
  self.key = value.nil? ? nil : [value].pack("H*")
end

#hex_salt=(value) ⇒ Object

Decodes hex-encoded salt and sets it to #salt

Parameters:

  • value (String)

    hex-encoded signature salt



40
41
42
# File 'lib/imgproxy/config.rb', line 40

def hex_salt=(value)
  self.salt = value.nil? ? nil : [value].pack("H*")
end

#url_adaptersImgproxy::UrlAdapters

URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc.

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

Imgproxy.url_for(user.avatar)

Returns:

See Also:



54
55
56
# File 'lib/imgproxy/config.rb', line 54

def url_adapters
  @url_adapters ||= Imgproxy::UrlAdapters.new
end