Class: Imgproxy::Config
- Inherits:
-
Object
- Object
- Imgproxy::Config
- Defined in:
- lib/imgproxy/config.rb
Overview
Imgproxy config
Instance Attribute Summary collapse
-
#base64_encode_urls ⇒ Boolean
Base64 encode the URL Defaults to false.
-
#endpoint ⇒ String
Imgproxy endpoint.
-
#key ⇒ String
Imgproxy signature key.
-
#salt ⇒ String
Imgproxy signature salt.
-
#signature_size ⇒ Integer
Imgproxy signature size.
-
#use_short_options ⇒ Boolean
Use short processing option names (
rsforresize,gforgravity, etc).
Instance Method Summary collapse
-
#hex_key=(value) ⇒ Object
Decodes hex-encoded key and sets it to #key.
-
#hex_salt=(value) ⇒ Object
Decodes hex-encoded salt and sets it to #salt.
-
#initialize ⇒ Config
constructor
A new instance of Config.
-
#url_adapters ⇒ Imgproxy::UrlAdapters
URL adapters config.
Constructor Details
#initialize ⇒ Config
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. = true self.base64_encode_urls = false end |
Instance Attribute Details
#base64_encode_urls ⇒ Boolean
Returns 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 |
#endpoint ⇒ String
Returns imgproxy endpoint.
8 9 10 |
# File 'lib/imgproxy/config.rb', line 8 def endpoint @endpoint end |
#key ⇒ String
Returns imgproxy signature key.
10 11 12 |
# File 'lib/imgproxy/config.rb', line 10 def key @key end |
#salt ⇒ String
Returns imgproxy signature salt.
12 13 14 |
# File 'lib/imgproxy/config.rb', line 12 def salt @salt end |
#signature_size ⇒ Integer
Returns imgproxy signature size. Defaults to 32.
14 15 16 |
# File 'lib/imgproxy/config.rb', line 14 def signature_size @signature_size end |
#use_short_options ⇒ Boolean
Returns 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 end |
Instance Method Details
#hex_key=(value) ⇒ Object
Decodes hex-encoded key and sets it to #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
40 41 42 |
# File 'lib/imgproxy/config.rb', line 40 def hex_salt=(value) self.salt = value.nil? ? nil : [value].pack("H*") end |
#url_adapters ⇒ Imgproxy::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)
54 55 56 |
# File 'lib/imgproxy/config.rb', line 54 def url_adapters @url_adapters ||= Imgproxy::UrlAdapters.new end |