Skip to content

Commit d438ff5

Browse files
authored
Merge pull request #180 from mrexox/feature/add-attachment-option
Add attachment option
2 parents 2c062f7 + ba77cd0 commit d438ff5

5 files changed

Lines changed: 9 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -235,6 +235,7 @@ builder.url_for("http://images.example.com/images/image2.jpg")
235235
- [auto_rotate](https://docs.imgproxy.net/#/generating_the_url_advanced?id=auto-rotate)
236236
- [filename](https://docs.imgproxy.net/#/generating_the_url_advanced?id=filename)
237237
- [format](https://docs.imgproxy.net/#/generating_the_url_advanced?id=format)
238+
- [return_attachment](https://docs.imgproxy.net/#/generating_the_url_advanced?id=return-attachment)
238239

239240
_See [imgproxy URL format guide](https://docs.imgproxy.net/#/generating_the_url_advanced?id=processing-options) for more info._
240241

lib/imgproxy.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,7 @@ def configure
100100
# @option options [Boolean] :auto_rotate
101101
# @option options [String] :filename
102102
# @option options [String] :format
103+
# @option options [Boolean] :attachment
103104
# @option options [Boolean] :use_short_options
104105
# @option options [Boolean] :base64_encode_urls
105106
# @option options [Boolean] :escape_plain_url

lib/imgproxy/options.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ class Options < Hash
6464
auto_rotate: Imgproxy::OptionsCasters::Bool,
6565
filename: Imgproxy::OptionsCasters::String,
6666
format: Imgproxy::OptionsCasters::String,
67+
return_attachment: Imgproxy::OptionsCasters::Bool,
6768
}.freeze
6869

6970
META = %i[size resize adjust].freeze

lib/imgproxy/options_aliases.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,5 +39,6 @@ module Imgproxy
3939
strip_color_profile: :scp,
4040
auto_rotate: :ar,
4141
filename: :fn,
42+
return_attachment: :att,
4243
}.freeze
4344
end

spec/imgproxy_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@
120120
auto_rotate: true,
121121
filename: "the_image.jpg",
122122
format: :webp,
123+
return_attachment: true,
123124
}
124125
end
125126

@@ -164,7 +165,8 @@
164165
"sm:1/"\
165166
"scp:0/"\
166167
"ar:1/"\
167-
"fn:the_image.jpg"
168+
"fn:the_image.jpg/"\
169+
"att:1"
168170
end
169171

170172
let(:casted_options_full) do
@@ -207,7 +209,8 @@
207209
"strip_metadata:1/"\
208210
"strip_color_profile:0/"\
209211
"auto_rotate:1/"\
210-
"filename:the_image.jpg"
212+
"filename:the_image.jpg/"\
213+
"return_attachment:1"
211214
end
212215
# rubocop: enable Layout/LineEndStringConcatenationIndentation
213216

0 commit comments

Comments
 (0)