paperclip-cloudinary 1.1.0 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/README.md +41 -2
- data/lib/paperclip/cloudinary/version.rb +1 -1
- data/lib/paperclip/storage/cloudinary.rb +18 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 991caf710e11807bfa06aae6188801216d9358c1
|
4
|
+
data.tar.gz: d1367fd08d75492adb8c958ee1ebf1ad7bff9bdf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 75319debfce96d914576815c8c4f564da17a5ce89e269a9c979091fa82247283b0b7b7f38997dfef9f55f45bd1a4216955e78203472363f30f597c4c06faf72c
|
7
|
+
data.tar.gz: c6aa1be805712f6bf7e350cb0ad0935d66a17711d9e76d715384d36a474d4de02103c0991b45f0d0bcce59562ee1e176f51dd6da816c47b0ccf0da3dbfafc6df
|
data/Gemfile.lock
CHANGED
data/README.md
CHANGED
@@ -114,8 +114,7 @@ has_attached_file :image,
|
|
114
114
|
]
|
115
115
|
}
|
116
116
|
}
|
117
|
-
|
118
|
-
}
|
117
|
+
}
|
119
118
|
```
|
120
119
|
|
121
120
|
Here, all image versions would be uploaded with a caption taken from the model's caption parameter and
|
@@ -126,6 +125,46 @@ facial recognition features.
|
|
126
125
|
|
127
126
|
The gem-provided default options can not be overridden.
|
128
127
|
|
128
|
+
### URL Options
|
129
|
+
|
130
|
+
One of Cloudinary's biggest draws is the ability to manipulate images
|
131
|
+
on the fly via URL parameters. You can specify the URL options in your
|
132
|
+
attachment configuration as well as in-line. See the Cloudinary
|
133
|
+
documentation for a list of all supported parameters.
|
134
|
+
|
135
|
+
#### Attachment Configuration
|
136
|
+
|
137
|
+
```ruby
|
138
|
+
has_attached_file :image
|
139
|
+
:storage => :cloudinary,
|
140
|
+
:styles => { :avatar => '200x200>' },
|
141
|
+
:cloudinary_url_options => {
|
142
|
+
:default => {
|
143
|
+
:secure => true
|
144
|
+
},
|
145
|
+
:styles => {
|
146
|
+
:avatar => {
|
147
|
+
:resource_type => 'raw'
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
```
|
152
|
+
|
153
|
+
Like upload options, the default options (optional) will be used first
|
154
|
+
for all calls, then the style-specific ones, if applicable.
|
155
|
+
|
156
|
+
#### In-line Configuration
|
157
|
+
|
158
|
+
```ruby
|
159
|
+
model.image.url(:avatar, :cloudinary => { :secure => true,
|
160
|
+
:resource_type => 'raw' }
|
161
|
+
```
|
162
|
+
|
163
|
+
These can be use in addition to the URL options provided in the
|
164
|
+
attachment configuration, or they can be used standalone. Options
|
165
|
+
provided in-line will override any options specified in the attachment
|
166
|
+
configuration.
|
167
|
+
|
129
168
|
## Contributing
|
130
169
|
|
131
170
|
Bug reports and pull requests are welcome on GitHub at https://github.com/GoGoCarl/paperclip-cloudinary.
|
@@ -45,7 +45,7 @@ module Paperclip
|
|
45
45
|
|
46
46
|
def flush_deletes
|
47
47
|
@queued_for_delete.each do |path|
|
48
|
-
::Cloudinary::Uploader.destroy path
|
48
|
+
::Cloudinary::Uploader.destroy path[0..-(File.extname(path).length + 1)]
|
49
49
|
end
|
50
50
|
|
51
51
|
@queued_for_delete.clear
|
@@ -68,7 +68,8 @@ module Paperclip
|
|
68
68
|
else
|
69
69
|
style = style_or_options
|
70
70
|
end
|
71
|
-
|
71
|
+
inline_opts = options[:cloudinary] || {}
|
72
|
+
::Cloudinary::Utils.cloudinary_url path(style), cloudinary_url_options(style, inline_opts)
|
72
73
|
end
|
73
74
|
|
74
75
|
def public_id style
|
@@ -102,6 +103,21 @@ module Paperclip
|
|
102
103
|
|
103
104
|
private
|
104
105
|
|
106
|
+
def cloudinary_url_options style_name, inline_opts={}
|
107
|
+
url_opts = @options[:cloudinary_url_options] || {}
|
108
|
+
default_opts = url_opts[:default] || {}
|
109
|
+
style_opts = url_opts[:styles].try(:[], style_name) || {}
|
110
|
+
|
111
|
+
options = {}
|
112
|
+
[default_opts, style_opts, inline_opts].each do |opts|
|
113
|
+
options.deep_merge!(opts) do |key, existing_value, new_value|
|
114
|
+
new_value.try(:call, style_name, self) || new_value
|
115
|
+
end
|
116
|
+
end
|
117
|
+
options.merge! default_opts
|
118
|
+
options
|
119
|
+
end
|
120
|
+
|
105
121
|
def find_credentials creds
|
106
122
|
case creds
|
107
123
|
when File
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip-cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.2.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Carl Scott
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-
|
11
|
+
date: 2016-06-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: cloudinary
|