dynamic_image 2.1.0 → 2.1.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/dynamic_image/controller.rb +23 -12
- data/lib/dynamic_image/errors.rb +6 -0
- data/lib/dynamic_image/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 814628e7438a06292a2a283be0c88b724a1449327276c2f7ca89656947c690d7
|
4
|
+
data.tar.gz: 8ff9d551e13362514d102cae1c04e61d3374689282715911448019c425c12487
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c52354d7f7100b367b402ea9be16a522872d423e8f1a21f49482bc86eb6223ac9d0c1194979e1d6b49fcfac2352922460aa44395e37adef1ca8cac0c6009e2b6
|
7
|
+
data.tar.gz: 94c370ea4a7ab9fe575ae324f8d50844c6600c5a677efcfe03471703130b4eea7613c5e3ac48d894481a1520484efdae2843ef90e36486f114009aa168681d1e
|
@@ -51,6 +51,24 @@ module DynamicImage
|
|
51
51
|
@record = model.find(params[:id])
|
52
52
|
end
|
53
53
|
|
54
|
+
def process_and_send(image, options)
|
55
|
+
processed_image = DynamicImage::ProcessedImage.new(image, options)
|
56
|
+
if process_later?(processed_image, requested_size)
|
57
|
+
process_later(image, options, requested_size)
|
58
|
+
head 503, retry_after: 10
|
59
|
+
else
|
60
|
+
send_image(processed_image, requested_size)
|
61
|
+
end
|
62
|
+
rescue MiniMagick::Error
|
63
|
+
process_later(image, options, requested_size)
|
64
|
+
raise
|
65
|
+
end
|
66
|
+
|
67
|
+
def process_later(image, options, requested_size)
|
68
|
+
DynamicImage::Jobs::CreateVariant
|
69
|
+
.perform_later(image, options, requested_size.to_s)
|
70
|
+
end
|
71
|
+
|
54
72
|
def process_later?(processed_image, size)
|
55
73
|
return false unless DynamicImage.process_later_limit
|
56
74
|
|
@@ -68,7 +86,7 @@ module DynamicImage
|
|
68
86
|
layout: false, locals: { options: options })
|
69
87
|
end
|
70
88
|
format.any(:gif, :jpeg, :jpg, :png, :tiff, :webp) do
|
71
|
-
|
89
|
+
process_and_send(@record, options)
|
72
90
|
end
|
73
91
|
end
|
74
92
|
end
|
@@ -90,17 +108,10 @@ module DynamicImage
|
|
90
108
|
params[:format]
|
91
109
|
end
|
92
110
|
|
93
|
-
def send_image(
|
94
|
-
processed_image
|
95
|
-
|
96
|
-
|
97
|
-
.perform_later(image, options, requested_size.to_s)
|
98
|
-
head 503, retry_after: 10
|
99
|
-
else
|
100
|
-
send_data(processed_image.cropped_and_resized(requested_size),
|
101
|
-
content_type: processed_image.content_type,
|
102
|
-
disposition: "inline")
|
103
|
-
end
|
111
|
+
def send_image(processed_image, requested_size)
|
112
|
+
send_data(processed_image.cropped_and_resized(requested_size),
|
113
|
+
content_type: processed_image.content_type,
|
114
|
+
disposition: "inline")
|
104
115
|
end
|
105
116
|
|
106
117
|
def verify_signed_params
|
data/lib/dynamic_image/errors.rb
CHANGED
@@ -3,11 +3,17 @@
|
|
3
3
|
module DynamicImage
|
4
4
|
module Errors
|
5
5
|
class Error < StandardError; end
|
6
|
+
|
6
7
|
class InvalidImage < DynamicImage::Errors::Error; end
|
8
|
+
|
7
9
|
class InvalidHeader < DynamicImage::Errors::Error; end
|
10
|
+
|
8
11
|
class InvalidSignature < DynamicImage::Errors::Error; end
|
12
|
+
|
9
13
|
class InvalidSizeOptions < DynamicImage::Errors::Error; end
|
14
|
+
|
10
15
|
class InvalidTransformation < DynamicImage::Errors::Error; end
|
16
|
+
|
11
17
|
class ParameterMissing < DynamicImage::Errors::Error; end
|
12
18
|
end
|
13
19
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: dynamic_image
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.1.
|
4
|
+
version: 2.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Inge Jørgensen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-01-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: dis
|
@@ -202,7 +202,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
202
202
|
- !ruby/object:Gem::Version
|
203
203
|
version: '0'
|
204
204
|
requirements: []
|
205
|
-
rubygems_version: 3.1.
|
205
|
+
rubygems_version: 3.1.4
|
206
206
|
signing_key:
|
207
207
|
specification_version: 4
|
208
208
|
summary: Rails plugin that simplifies image uploading and processing
|