dynamic_image 2.0.3 → 2.0.4
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 +19 -10
- data/lib/dynamic_image/helper.rb +14 -0
- data/lib/dynamic_image/routing.rb +1 -0
- data/lib/dynamic_image/templates/show.html.erb +1 -0
- data/lib/dynamic_image/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c82de9910001e6bd9b12219dbf0b7c3fe205ed1f
|
4
|
+
data.tar.gz: 57289784675b4655201fc50745c1b649530f7181
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1fe98b98e7a733b98560040cf3b98176dff97d7cdce28aaa7c019d24ad4c590a079870654cfe5648edd3d93f8c7f275e46108b9568cc67bbe00ff1ed295004ed
|
7
|
+
data.tar.gz: 5c24baa739944fcaa6f695fc370d5b098373235d252172b2c9050a52752772875667db4e6b01719f77e6a9dddba73e4e6997cb543fa50fbc4ec235abb1477ecd
|
@@ -29,16 +29,11 @@ module DynamicImage
|
|
29
29
|
|
30
30
|
# Renders the original image data, without any processing.
|
31
31
|
def original
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
content_type: @record.content_type,
|
38
|
-
disposition: "inline"
|
39
|
-
)
|
40
|
-
end
|
41
|
-
end
|
32
|
+
render_raw_image
|
33
|
+
end
|
34
|
+
|
35
|
+
def download
|
36
|
+
render_raw_image(disposition: "attachment", filename: @record.filename)
|
42
37
|
end
|
43
38
|
|
44
39
|
# Returns the requested size as a vector.
|
@@ -69,6 +64,20 @@ module DynamicImage
|
|
69
64
|
end
|
70
65
|
end
|
71
66
|
|
67
|
+
def render_raw_image(disposition: "inline", filename: nil)
|
68
|
+
return unless stale?(@record)
|
69
|
+
respond_to do |format|
|
70
|
+
format.any(:gif, :jpeg, :png, :tiff) do
|
71
|
+
send_data(
|
72
|
+
@record.data,
|
73
|
+
filename: filename,
|
74
|
+
content_type: @record.content_type,
|
75
|
+
disposition: disposition
|
76
|
+
)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
72
81
|
def requested_format
|
73
82
|
params[:format]
|
74
83
|
end
|
data/lib/dynamic_image/helper.rb
CHANGED
@@ -70,6 +70,20 @@ module DynamicImage
|
|
70
70
|
dynamic_image_url_with_size(record_or_array, size, options)
|
71
71
|
end
|
72
72
|
|
73
|
+
# Returns a path to the original uploaded file for download,
|
74
|
+
# without any processing applied. Sizing options are not
|
75
|
+
# supported.
|
76
|
+
def download_dynamic_image_path(record_or_array, options = {})
|
77
|
+
dynamic_image_path(record_or_array, { action: :download }.merge(options))
|
78
|
+
end
|
79
|
+
|
80
|
+
# Returns a URL to the original uploaded file for download,
|
81
|
+
# without any processing applied. Sizing options are not
|
82
|
+
# supported.
|
83
|
+
def download_dynamic_image_url(record_or_array, options = {})
|
84
|
+
dynamic_image_url(record_or_array, { action: :download }.merge(options))
|
85
|
+
end
|
86
|
+
|
73
87
|
# Returns a path to the original uploaded file, without any processing
|
74
88
|
# applied. Sizing options are not supported.
|
75
89
|
def original_dynamic_image_path(record_or_array, options = {})
|