imgproxy 1.0.6 → 2.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +236 -92
  3. data/lib/imgproxy/builder.rb +54 -37
  4. data/lib/imgproxy/config.rb +96 -25
  5. data/lib/imgproxy/extensions/active_storage.rb +10 -0
  6. data/lib/imgproxy/extensions/shrine.rb +10 -0
  7. data/lib/imgproxy/options.rb +87 -72
  8. data/lib/imgproxy/options_aliases.rb +43 -0
  9. data/lib/imgproxy/options_casters/adjust.rb +22 -0
  10. data/lib/imgproxy/options_casters/array.rb +12 -0
  11. data/lib/imgproxy/options_casters/base64.rb +12 -0
  12. data/lib/imgproxy/options_casters/bool.rb +12 -0
  13. data/lib/imgproxy/options_casters/crop.rb +23 -0
  14. data/lib/imgproxy/options_casters/extend.rb +26 -0
  15. data/lib/imgproxy/options_casters/float.rb +16 -0
  16. data/lib/imgproxy/options_casters/gif_options.rb +21 -0
  17. data/lib/imgproxy/options_casters/gravity.rb +23 -0
  18. data/lib/imgproxy/options_casters/group.rb +21 -0
  19. data/lib/imgproxy/options_casters/integer.rb +10 -0
  20. data/lib/imgproxy/options_casters/jpeg_options.rb +26 -0
  21. data/lib/imgproxy/options_casters/png_options.rb +23 -0
  22. data/lib/imgproxy/options_casters/resize.rb +21 -0
  23. data/lib/imgproxy/options_casters/size.rb +24 -0
  24. data/lib/imgproxy/options_casters/string.rb +10 -0
  25. data/lib/imgproxy/options_casters/trim.rb +28 -0
  26. data/lib/imgproxy/options_casters/watermark.rb +30 -0
  27. data/lib/imgproxy/trim_array.rb +11 -0
  28. data/lib/imgproxy/url_adapters/active_storage.rb +25 -0
  29. data/lib/imgproxy/url_adapters/shrine.rb +15 -5
  30. data/lib/imgproxy/url_adapters.rb +0 -4
  31. data/lib/imgproxy/version.rb +1 -1
  32. data/lib/imgproxy.rb +78 -38
  33. metadata +69 -24
  34. data/lib/imgproxy/url_adapters/active_storage_gcs.rb +0 -31
  35. data/lib/imgproxy/url_adapters/active_storage_s3.rb +0 -23
  36. data/lib/imgproxy/url_adapters/shrine_s3.rb +0 -20
@@ -0,0 +1,12 @@
1
+ module Imgproxy
2
+ module OptionsCasters
3
+ # Casts boolean option
4
+ module Bool
5
+ def self.cast(raw)
6
+ return if raw.nil?
7
+
8
+ raw && raw != 0 && raw != "0" ? 1 : 0
9
+ end
10
+ end
11
+ end
12
+ end
@@ -0,0 +1,23 @@
1
+ require "imgproxy/trim_array"
2
+ require "imgproxy/options_casters/float"
3
+ require "imgproxy/options_casters/gravity"
4
+
5
+ module Imgproxy
6
+ module OptionsCasters
7
+ # Casts crop option
8
+ module Crop
9
+ using TrimArray
10
+
11
+ def self.cast(raw)
12
+ return raw unless raw.is_a?(Hash)
13
+ return unless raw[:width] || raw[:height]
14
+
15
+ [
16
+ Imgproxy::OptionsCasters::Float.cast(raw[:width]) || 0,
17
+ Imgproxy::OptionsCasters::Float.cast(raw[:height]) || 0,
18
+ Imgproxy::OptionsCasters::Gravity.cast(raw[:gravity]),
19
+ ].trim!
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,26 @@
1
+ require "imgproxy/options_casters/group"
2
+ require "imgproxy/options_casters/bool"
3
+ require "imgproxy/options_casters/gravity"
4
+
5
+ module Imgproxy
6
+ module OptionsCasters
7
+ # Casts extend option
8
+ module Extend
9
+ CASTER = Imgproxy::OptionsCasters::Group.new(
10
+ extend: Imgproxy::OptionsCasters::Bool,
11
+ gravity: Imgproxy::OptionsCasters::Gravity,
12
+ ).freeze
13
+
14
+ def self.cast(raw)
15
+ # Allow extend to be just a boolean
16
+ return Imgproxy::OptionsCasters::Bool.cast(raw) if [true, false].include?(raw)
17
+
18
+ return raw unless raw.is_a?(Hash)
19
+ return if raw[:extend].nil?
20
+
21
+ values = CASTER.cast(raw)
22
+ values[0].zero? ? 0 : values
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,16 @@
1
+ module Imgproxy
2
+ module OptionsCasters
3
+ # Casts float option
4
+ module Float
5
+ ZERO_RE = /\.0+/.freeze
6
+
7
+ def self.cast(raw)
8
+ raw&.to_f&.yield_self do |f|
9
+ # Convert integral value to Integer so to_s won't give us trailing zero
10
+ i = f.to_i
11
+ i == f ? i : f
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,21 @@
1
+ require "imgproxy/options_casters/group"
2
+ require "imgproxy/options_casters/bool"
3
+
4
+ module Imgproxy
5
+ module OptionsCasters
6
+ # Casts gif_options option
7
+ module GifOptions
8
+ CASTER = Imgproxy::OptionsCasters::Group.new(
9
+ optimize_frames: Imgproxy::OptionsCasters::Bool,
10
+ optimize_transparency: Imgproxy::OptionsCasters::Bool,
11
+ ).freeze
12
+
13
+ def self.cast(raw)
14
+ return raw unless raw.is_a?(Hash)
15
+
16
+ values = CASTER.cast(raw)
17
+ values.empty? ? nil : values
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,23 @@
1
+ require "imgproxy/options_casters/group"
2
+ require "imgproxy/options_casters/string"
3
+ require "imgproxy/options_casters/float"
4
+
5
+ module Imgproxy
6
+ module OptionsCasters
7
+ # Casts gravity option
8
+ module Gravity
9
+ CASTER = Imgproxy::OptionsCasters::Group.new(
10
+ type: Imgproxy::OptionsCasters::String,
11
+ x_offset: Imgproxy::OptionsCasters::Float,
12
+ y_offset: Imgproxy::OptionsCasters::Float,
13
+ ).freeze
14
+
15
+ def self.cast(raw)
16
+ return raw unless raw.is_a?(Hash)
17
+ return unless raw[:type]
18
+
19
+ CASTER.cast(raw)
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ require "imgproxy/trim_array"
2
+
3
+ module Imgproxy
4
+ module OptionsCasters
5
+ # Casts group of options and trim nils from the end
6
+ class Group
7
+ using TrimArray
8
+
9
+ def initialize(extractors)
10
+ @extractors = extractors
11
+ end
12
+
13
+ def cast(raw)
14
+ values = @extractors.map do |key, extractor|
15
+ extractor.cast(raw[key])
16
+ end
17
+ values.trim!
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,10 @@
1
+ module Imgproxy
2
+ module OptionsCasters
3
+ # Casts integer option
4
+ module Integer
5
+ def self.cast(raw)
6
+ raw&.to_i
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,26 @@
1
+ require "imgproxy/options_casters/group"
2
+ require "imgproxy/options_casters/bool"
3
+ require "imgproxy/options_casters/integer"
4
+
5
+ module Imgproxy
6
+ module OptionsCasters
7
+ # Casts jpeg_options option
8
+ module JpegOptions
9
+ CASTER = Imgproxy::OptionsCasters::Group.new(
10
+ progressive: Imgproxy::OptionsCasters::Bool,
11
+ no_subsample: Imgproxy::OptionsCasters::Bool,
12
+ trellis_quant: Imgproxy::OptionsCasters::Bool,
13
+ overshoot_deringing: Imgproxy::OptionsCasters::Bool,
14
+ optimize_scans: Imgproxy::OptionsCasters::Bool,
15
+ quant_table: Imgproxy::OptionsCasters::Integer,
16
+ ).freeze
17
+
18
+ def self.cast(raw)
19
+ return raw unless raw.is_a?(Hash)
20
+
21
+ values = CASTER.cast(raw)
22
+ values.empty? ? nil : values
23
+ end
24
+ end
25
+ end
26
+ end
@@ -0,0 +1,23 @@
1
+ require "imgproxy/options_casters/group"
2
+ require "imgproxy/options_casters/bool"
3
+ require "imgproxy/options_casters/integer"
4
+
5
+ module Imgproxy
6
+ module OptionsCasters
7
+ # Casts png_options option
8
+ module PngOptions
9
+ CASTER = Imgproxy::OptionsCasters::Group.new(
10
+ interlaced: Imgproxy::OptionsCasters::Bool,
11
+ quantize: Imgproxy::OptionsCasters::Bool,
12
+ quantization_colors: Imgproxy::OptionsCasters::Integer,
13
+ ).freeze
14
+
15
+ def self.cast(raw)
16
+ return raw unless raw.is_a?(Hash)
17
+
18
+ values = CASTER.cast(raw)
19
+ values.empty? ? nil : values
20
+ end
21
+ end
22
+ end
23
+ end
@@ -0,0 +1,21 @@
1
+ require "imgproxy/trim_array"
2
+ require "imgproxy/options_casters/string"
3
+ require "imgproxy/options_casters/size"
4
+
5
+ module Imgproxy
6
+ module OptionsCasters
7
+ # Casts resize option
8
+ module Resize
9
+ using TrimArray
10
+
11
+ def self.cast(raw)
12
+ return raw unless raw.is_a?(Hash)
13
+
14
+ [
15
+ Imgproxy::OptionsCasters::String.cast(raw[:resizing_type]) || "fit",
16
+ *Imgproxy::OptionsCasters::Size.cast(raw),
17
+ ].trim!
18
+ end
19
+ end
20
+ end
21
+ end
@@ -0,0 +1,24 @@
1
+ require "imgproxy/trim_array"
2
+ require "imgproxy/options_casters/integer"
3
+ require "imgproxy/options_casters/bool"
4
+ require "imgproxy/options_casters/extend"
5
+
6
+ module Imgproxy
7
+ module OptionsCasters
8
+ # Casts size option
9
+ module Size
10
+ using TrimArray
11
+
12
+ def self.cast(raw)
13
+ return raw unless raw.is_a?(Hash)
14
+
15
+ [
16
+ Imgproxy::OptionsCasters::Integer.cast(raw[:width]) || 0,
17
+ Imgproxy::OptionsCasters::Integer.cast(raw[:height]) || 0,
18
+ Imgproxy::OptionsCasters::Bool.cast(raw[:enlarge]),
19
+ Imgproxy::OptionsCasters::Extend.cast(raw[:extend]),
20
+ ].trim!
21
+ end
22
+ end
23
+ end
24
+ end
@@ -0,0 +1,10 @@
1
+ module Imgproxy
2
+ module OptionsCasters
3
+ # Casts string option
4
+ module String
5
+ def self.cast(raw)
6
+ raw&.to_s
7
+ end
8
+ end
9
+ end
10
+ end
@@ -0,0 +1,28 @@
1
+ require "imgproxy/options_casters/group"
2
+ require "imgproxy/options_casters/float"
3
+ require "imgproxy/options_casters/string"
4
+ require "imgproxy/options_casters/bool"
5
+
6
+ module Imgproxy
7
+ module OptionsCasters
8
+ # Casts trim option
9
+ module Trim
10
+ CASTER = Imgproxy::OptionsCasters::Group.new(
11
+ threshold: Imgproxy::OptionsCasters::Float,
12
+ color: Imgproxy::OptionsCasters::String,
13
+ equal_hor: Imgproxy::OptionsCasters::Bool,
14
+ equal_ver: Imgproxy::OptionsCasters::Bool,
15
+ ).freeze
16
+
17
+ def self.cast(raw)
18
+ # Allow trim to be just a numeric
19
+ return Imgproxy::OptionsCasters::Float.cast(raw) if raw.is_a?(Numeric)
20
+
21
+ return raw unless raw.is_a?(Hash)
22
+ return unless raw[:threshold]
23
+
24
+ CASTER.cast(raw)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -0,0 +1,30 @@
1
+ require "imgproxy/options_casters/group"
2
+ require "imgproxy/options_casters/float"
3
+ require "imgproxy/options_casters/string"
4
+ require "imgproxy/options_casters/integer"
5
+
6
+ module Imgproxy
7
+ module OptionsCasters
8
+ # Casts string option
9
+ module Watermark
10
+ CASTER = Imgproxy::OptionsCasters::Group.new(
11
+ opacity: Imgproxy::OptionsCasters::Float,
12
+ position: Imgproxy::OptionsCasters::String,
13
+ x_offset: Imgproxy::OptionsCasters::Integer,
14
+ y_offset: Imgproxy::OptionsCasters::Integer,
15
+ scale: Imgproxy::OptionsCasters::Float,
16
+ ).freeze
17
+
18
+ def self.cast(raw)
19
+ # Allow watermark to be just a numeric
20
+ return Imgproxy::OptionsCasters::Float.cast(raw) if raw.is_a?(Numeric)
21
+
22
+ return raw unless raw.is_a?(Hash)
23
+ return unless raw[:opacity]
24
+
25
+ values = CASTER.cast(raw)
26
+ values[0].zero? ? 0 : values
27
+ end
28
+ end
29
+ end
30
+ end
@@ -0,0 +1,11 @@
1
+ module Imgproxy
2
+ # `Array.trim!` refinement
3
+ module TrimArray
4
+ refine Array do
5
+ def trim!
6
+ delete_at(-1) while !empty? && last.nil?
7
+ self
8
+ end
9
+ end
10
+ end
11
+ end
@@ -15,8 +15,33 @@ module Imgproxy
15
15
  end
16
16
 
17
17
  def url(image)
18
+ return s3_url(image) if use_s3_url(image)
19
+ return gcs_url(image) if use_gcs_url(image)
20
+
18
21
  Rails.application.routes.url_helpers.url_for(image)
19
22
  end
23
+
24
+ private
25
+
26
+ def s3_url(image)
27
+ "s3://#{image.service.bucket.name}/#{image.key}"
28
+ end
29
+
30
+ def use_s3_url(image)
31
+ config.use_s3_urls && image.service.is_a?(::ActiveStorage::Service::S3Service)
32
+ end
33
+
34
+ def gcs_url(image)
35
+ "gs://#{config.gcs_bucket}/#{image.key}"
36
+ end
37
+
38
+ def use_gcs_url(image)
39
+ config.use_gcs_urls && image.service.is_a?(::ActiveStorage::Service::GCSService)
40
+ end
41
+
42
+ def config
43
+ Imgproxy.config
44
+ end
20
45
  end
21
46
  end
22
47
  end
@@ -8,19 +8,29 @@ module Imgproxy
8
8
  #
9
9
  # Imgproxy.url_for(user.avatar)
10
10
  class Shrine
11
- def initialize(host: nil)
12
- @host = host
13
- end
14
-
15
11
  def applicable?(image)
16
12
  image.is_a?(::Shrine::UploadedFile)
17
13
  end
18
14
 
19
15
  def url(image)
16
+ return s3_url(image) if use_s3_url(image)
17
+
20
18
  opts = {}
21
- opts[:host] = @host if @host
19
+ opts[:host] = Imgproxy.config.shrine_host if Imgproxy.config.shrine_host
22
20
  image.url(opts)
23
21
  end
22
+
23
+ private
24
+
25
+ def s3_url(image)
26
+ path = [*image.storage.prefix, image.id].join("/")
27
+ "s3://#{image.storage.bucket.name}/#{path}"
28
+ end
29
+
30
+ def use_s3_url(image)
31
+ Imgproxy.config.use_s3_urls &&
32
+ image.storage.is_a?(::Shrine::Storage::S3)
33
+ end
24
34
  end
25
35
  end
26
36
  end
@@ -1,9 +1,5 @@
1
1
  require "imgproxy/url_adapters/active_storage"
2
- require "imgproxy/url_adapters/active_storage_s3"
3
- require "imgproxy/url_adapters/active_storage_gcs"
4
-
5
2
  require "imgproxy/url_adapters/shrine"
6
- require "imgproxy/url_adapters/shrine_s3"
7
3
 
8
4
  module Imgproxy
9
5
  # URL adapters config. Allows to use this gem with ActiveStorage, Shrine, etc.
@@ -1,3 +1,3 @@
1
1
  module Imgproxy
2
- VERSION = "1.0.6".freeze
2
+ VERSION = "2.0.1".freeze
3
3
  end
data/lib/imgproxy.rb CHANGED
@@ -19,8 +19,8 @@ module Imgproxy
19
19
  #
20
20
  # Imgproxy.configure do |config|
21
21
  # config.endpoint = "http://imgproxy.example.com"
22
- # config.hex_key = "your_key"
23
- # config.hex_salt = "your_salt"
22
+ # config.key = "your_key"
23
+ # config.salt = "your_salt"
24
24
  # config.use_short_options = true
25
25
  # end
26
26
  #
@@ -38,72 +38,112 @@ module Imgproxy
38
38
  # width: 500,
39
39
  # height: 400,
40
40
  # resizing_type: :fill,
41
- # sharpen: 0.5
41
+ # sharpen: 0.5,
42
+ # gravity: {
43
+ # type: :soea,
44
+ # x_offset: 10,
45
+ # y_offset: 5,
46
+ # },
47
+ # crop: {
48
+ # width: 2000,
49
+ # height: 1000,
50
+ # gravity: {
51
+ # type: :nowe,
52
+ # x_offset: 20,
53
+ # y_offset: 30,
54
+ # },
55
+ # },
42
56
  # )
43
57
  #
44
58
  # @return [String] imgproxy URL
45
59
  # @param [String,URI, Object] image Source image URL or object applicable for
46
60
  # the configured URL adapters
47
61
  # @param [Hash] options Processing options
62
+ # @option options [Hash|Array|String] :resize
63
+ # @option options [Hash|Array|String] :size
48
64
  # @option options [String] :resizing_type
65
+ # @option options [String] :resizing_algorithm supported only by imgproxy pro
49
66
  # @option options [Integer] :width
50
67
  # @option options [Integer] :height
51
68
  # @option options [Float] :dpr
52
69
  # @option options [Boolean] :enlarge
53
- # @option options [Boolean] :extend
54
- # @option options [String] :gravity
55
- # @option options [Float] :gravity_x
56
- # @option options [Float] :gravity_y
70
+ # @option options [Hash|Array|Boolean|String] :extend
71
+ # @option options [Hash|Array|String] :gravity
72
+ # @option options [Hash|Array|String] :crop
73
+ # @option options [Array] :padding
74
+ # @option options [Hash|Array|String] :trim
75
+ # @option options [Integer] :rotate
57
76
  # @option options [Integer] :quality
58
- # @option options [Array] :background
77
+ # @option options [Integer] :max_bytes
78
+ # @option options [Array|String] :background
79
+ # @option options [Float] :background_alpha supported only by imgproxy pro
80
+ # @option options [Hash|Array|String] :adjust
81
+ # @option options [Integer] :brightness supported only by imgproxy pro
82
+ # @option options [Float] :contrast supported only by imgproxy pro
83
+ # @option options [Float] :saturation supported only by imgproxy pro
59
84
  # @option options [Float] :blur
60
85
  # @option options [Float] :sharpen
61
- # @option options [Float] :watermark_opacity
62
- # @option options [String] :watermark_position
63
- # @option options [Integer] :watermark_x_offset
64
- # @option options [Integer] :watermark_y_offset
65
- # @option options [Float] :watermark_scale
86
+ # @option options [Integer] :pixelate supported only by imgproxy pro
87
+ # @option options [String] :unsharpening supported only by imgproxy pro
88
+ # @option options [Hash|Array|Float|String] :watermark
89
+ # @option options [String] :watermark_url supported only by imgproxy pro
90
+ # @option options [String] :style supported only by imgproxy pro
91
+ # @option options [Hash|Array|String] :jpeg_options supported only by imgproxy pro
92
+ # @option options [Hash|Array|String] :png_options supported only by imgproxy pro
93
+ # @option options [Hash|Array|String] :gif_options supported only by imgproxy pro
94
+ # @option options [Integer] :page supported only by imgproxy pro
95
+ # @option options [Integer] :video_thumbnail_second supported only by imgproxy pro
66
96
  # @option options [Array] :preset
67
97
  # @option options [String] :cachebuster
98
+ # @option options [Boolean] :strip_metadata
99
+ # @option options [Boolean] :strip_color_profile
100
+ # @option options [Boolean] :auto_rotate
101
+ # @option options [String] :filename
68
102
  # @option options [String] :format
69
103
  # @option options [Boolean] :use_short_options
70
- # @see https://github.com/DarthSim/imgproxy/blob/master/docs/generating_the_url_advanced.md
71
- # imgproxy URL format documentation
104
+ # @option options [Boolean] :base64_encode_urls
105
+ # @option options [Boolean] :escape_plain_url
106
+ # @see https://docs.imgproxy.net/#/generating_the_url_advanced?id=processing-options
107
+ # Available imgproxy URL processing options and their arguments
72
108
  def url_for(image, options = {})
73
109
  Imgproxy::Builder.new(options).url_for(image)
74
110
  end
75
111
 
76
- # Extends ActiveStorage::Blob with {Imgproxy::Extensions::ActiveStorage.imgproxy_url} method
77
- # and adds URL adapters for ActiveStorage
112
+ # Genrates imgproxy info URL. Supported only by imgproxy pro
78
113
  #
79
- # @return [void]
80
- # @param use_s3 [Boolean] enable Amazon S3 source URLs
81
- # @param use_gcs [Boolean] enable Google Cloud Storage source URLs
82
- # @param gcs_bucket [String] Google Cloud Storage bucket name
83
- def extend_active_storage!(use_s3: false, use_gcs: false, gcs_bucket: nil)
84
- ActiveSupport.on_load(:active_storage_blob) do
85
- ::ActiveStorage::Blob.include Imgproxy::Extensions::ActiveStorage
114
+ # Imgproxy.info_url_for("http://images.example.com/images/image.jpg")
115
+ #
116
+ # @return [String] imgproxy info URL
117
+ # @param [String,URI, Object] image Source image URL or object applicable for
118
+ # the configured URL adapters
119
+ # @param [Hash] options Processing options
120
+ # @option options [Boolean] :base64_encode_urls
121
+ # @option options [Boolean] :escape_plain_url
122
+ def info_url_for(image, options = {})
123
+ Imgproxy::Builder.new(options).info_url_for(image)
124
+ end
86
125
 
87
- url_adapters = Imgproxy.config.url_adapters
126
+ # Extends +ActiveStorage::Blob+ with {Imgproxy::Extensions::ActiveStorage.imgproxy_url} method
127
+ # and adds URL adapters for ActiveStorage
128
+ def extend_active_storage!
129
+ return unless defined?(ActiveSupport) && ActiveSupport.respond_to?(:on_load)
88
130
 
89
- url_adapters.add(Imgproxy::UrlAdapters::ActiveStorageS3.new) if use_s3
90
- url_adapters.add(Imgproxy::UrlAdapters::ActiveStorageGCS.new(gcs_bucket)) if use_gcs
91
- url_adapters.add(Imgproxy::UrlAdapters::ActiveStorage.new)
131
+ ActiveSupport.on_load(:active_storage_blob) do
132
+ ::ActiveStorage::Blob.include Imgproxy::Extensions::ActiveStorage
133
+ Imgproxy.config.url_adapters.add(Imgproxy::UrlAdapters::ActiveStorage.new)
92
134
  end
93
135
  end
94
136
 
95
- # Extends Shrine::UploadedFile with {Imgproxy::Extensions::Shrine.imgproxy_url} method
137
+ # Extends +Shrine::UploadedFile+ with {Imgproxy::Extensions::Shrine.imgproxy_url} method
96
138
  # and adds URL adapters for Shrine
97
- #
98
- # @return [void]
99
- # @param use_s3 [Boolean] enable Amazon S3 source URLs
100
- def extend_shrine!(host: nil, use_s3: false)
101
- ::Shrine::UploadedFile.include Imgproxy::Extensions::Shrine
102
-
103
- url_adapters = Imgproxy.config.url_adapters
139
+ def extend_shrine!
140
+ return unless defined?(::Shrine::UploadedFile)
104
141
 
105
- url_adapters.add(Imgproxy::UrlAdapters::ShrineS3.new) if use_s3
106
- url_adapters.add(Imgproxy::UrlAdapters::Shrine.new(host: host))
142
+ ::Shrine::UploadedFile.include Imgproxy::Extensions::Shrine
143
+ Imgproxy.config.url_adapters.add(Imgproxy::UrlAdapters::Shrine.new)
107
144
  end
108
145
  end
109
146
  end
147
+
148
+ Imgproxy.extend_active_storage!
149
+ Imgproxy.extend_shrine!