dynamic_image 2.0.3 → 2.0.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d1600a4e263630c8a9936e6f8309add967434b81
4
- data.tar.gz: 1ad5ff2c9b894a0fd774797cc64395ed72d7b556
3
+ metadata.gz: c82de9910001e6bd9b12219dbf0b7c3fe205ed1f
4
+ data.tar.gz: 57289784675b4655201fc50745c1b649530f7181
5
5
  SHA512:
6
- metadata.gz: 6f60bf400b04b6c8b9b7fe9d59ea967796bd58171fbf258ba326349e128bd35bd50cbe49b779a82e6d7d3db0f70636ff7808d79dae2a1f0d1a4f15b96516bf00
7
- data.tar.gz: 74063c221b4948e5121f0be2f5b6a8244ed4bb25b9c3a44609cfcab902e648ccfee69697b060bdda5186183061ad950f2e71b9e382d674939d7b1367953b7f20
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
- return unless stale?(@record)
33
- respond_to do |format|
34
- format.any(:gif, :jpeg, :png, :tiff) do
35
- send_data(
36
- @record.data,
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
@@ -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 = {})
@@ -18,6 +18,7 @@ module DynamicImage
18
18
  resources resource_name, options do
19
19
  get :uncropped, on: :member
20
20
  get :original, on: :member
21
+ get :download, on: :member
21
22
  end
22
23
  end
23
24
  end
@@ -76,6 +76,7 @@
76
76
  size: requested_size,
77
77
  crop: true)) %>
78
78
  <%= link_to "Original", original_dynamic_image_path(@record) %>
79
+ <%= link_to "Download", download_dynamic_image_path(@record) %>
79
80
  </div>
80
81
 
81
82
  <table class="metadata">
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
2
 
3
3
  module DynamicImage
4
- VERSION = "2.0.3".freeze
4
+ VERSION = "2.0.4".freeze
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: dynamic_image
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Inge Jørgensen