cloudinary 1.0.57 → 1.0.58
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.
- data/README.md +5 -0
- data/lib/cloudinary/helper.rb +21 -17
- data/lib/cloudinary/utils.rb +2 -2
- data/lib/cloudinary/version.rb +1 -1
- data/spec/utils_spec.rb +5 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -155,6 +155,11 @@ For more details on CarrierWave integration see [our documentation](http://cloud
|
|
155
155
|
|
156
156
|
We also published an interesting blog post about [Ruby on Rails image uploads with CarrierWave and Cloudinary](http://cloudinary.com/blog/ruby_on_rails_image_uploads_with_carrierwave_and_cloudinary).
|
157
157
|
|
158
|
+
### Samples
|
159
|
+
|
160
|
+
You can find our simple and ready-to-use samples projects, along with documentation in the [samples folder](https://github.com/cloudinary/cloudinary_gem/tree/master/samples).
|
161
|
+
Please consult with the [README file](https://github.com/cloudinary/cloudinary_gem/blob/master/samples/README.md), for usage and explanations.
|
162
|
+
|
158
163
|
|
159
164
|
## Additional resources ##########################################################
|
160
165
|
|
data/lib/cloudinary/helper.rb
CHANGED
@@ -9,7 +9,7 @@ module CloudinaryHelper
|
|
9
9
|
# cl_image_tag "israel.png", :width=>100, :height=>100, :alt=>"hello", :crop=>:fit # W/H are sent to cloudinary
|
10
10
|
def cl_image_tag(source, options = {})
|
11
11
|
options = options.clone
|
12
|
-
source =
|
12
|
+
source = cloudinary_url_internal(source, options)
|
13
13
|
options[:width] = options.delete(:html_width) if options.include?(:html_width)
|
14
14
|
options[:height] = options.delete(:html_height) if options.include?(:html_height)
|
15
15
|
options[:size] = options.delete(:html_size) if options.include?(:html_size)
|
@@ -20,7 +20,7 @@ module CloudinaryHelper
|
|
20
20
|
|
21
21
|
def cl_image_path(source, options = {})
|
22
22
|
options = options.clone
|
23
|
-
url =
|
23
|
+
url = cloudinary_url_internal(source, options)
|
24
24
|
original_image_path(url)
|
25
25
|
end
|
26
26
|
|
@@ -98,7 +98,7 @@ module CloudinaryHelper
|
|
98
98
|
end
|
99
99
|
|
100
100
|
options[:format] = "css" unless source.ends_with?(".css")
|
101
|
-
|
101
|
+
cloudinary_url_internal(source, options.merge(:type=>:sprite))
|
102
102
|
end
|
103
103
|
|
104
104
|
def cl_sprite_tag(source, options = {})
|
@@ -143,20 +143,9 @@ module CloudinaryHelper
|
|
143
143
|
end
|
144
144
|
|
145
145
|
def cloudinary_url(source, options = {})
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
options[:transformation] = Cloudinary::Utils.build_array(source.transformation) + Cloudinary::Utils.build_array(options[:transformation])
|
150
|
-
end
|
151
|
-
options.reverse_merge!(
|
152
|
-
:resource_type => Cloudinary::Utils.resource_type_for_format(source.filename || source.format),
|
153
|
-
:type => source.storage_type,
|
154
|
-
:format => source.format)
|
155
|
-
source = source.full_public_id
|
156
|
-
end
|
157
|
-
Cloudinary::Utils.cloudinary_url(source, options)
|
158
|
-
end
|
159
|
-
|
146
|
+
cloudinary_url_internal(source, options.clone)
|
147
|
+
end
|
148
|
+
|
160
149
|
def cl_image_upload(object_name, method, options={})
|
161
150
|
cl_image_upload_tag("#{object_name}[#{method}]", options)
|
162
151
|
end
|
@@ -199,6 +188,21 @@ module CloudinaryHelper
|
|
199
188
|
end
|
200
189
|
|
201
190
|
private
|
191
|
+
def cloudinary_url_internal(source, options = {})
|
192
|
+
options[:ssl_detected] = request.ssl? if defined?(request) && request && request.respond_to?(:ssl?)
|
193
|
+
if defined?(CarrierWave::Uploader::Base) && source.is_a?(CarrierWave::Uploader::Base)
|
194
|
+
if source.version_name.present?
|
195
|
+
options[:transformation] = Cloudinary::Utils.build_array(source.transformation) + Cloudinary::Utils.build_array(options[:transformation])
|
196
|
+
end
|
197
|
+
options.reverse_merge!(
|
198
|
+
:resource_type => Cloudinary::Utils.resource_type_for_format(source.filename || source.format),
|
199
|
+
:type => source.storage_type,
|
200
|
+
:format => source.format)
|
201
|
+
source = source.full_public_id
|
202
|
+
end
|
203
|
+
Cloudinary::Utils.cloudinary_url(source, options)
|
204
|
+
end
|
205
|
+
|
202
206
|
def build_callback_url(options)
|
203
207
|
callback_path = options.delete(:callback_cors) || Cloudinary.config.callback_cors || "/cloudinary_cors.html"
|
204
208
|
if !callback_path.match(/^https?:\/\//)
|
data/lib/cloudinary/utils.rb
CHANGED
@@ -26,7 +26,7 @@ class Cloudinary::Utils
|
|
26
26
|
crop = options.delete(:crop)
|
27
27
|
angle = build_array(options.delete(:angle)).join(".")
|
28
28
|
|
29
|
-
no_html_sizes = has_layer || !angle.blank? || crop.to_s == "fit" || crop.to_s == "limit"
|
29
|
+
no_html_sizes = has_layer || !angle.blank? || crop.to_s == "fit" || crop.to_s == "limit" || crop.to_s == "lfill"
|
30
30
|
options.delete(:width) if width && (width.to_f < 1 || no_html_sizes)
|
31
31
|
options.delete(:height) if height && (height.to_f < 1 || no_html_sizes)
|
32
32
|
|
@@ -263,7 +263,7 @@ class Cloudinary::Utils
|
|
263
263
|
end
|
264
264
|
end
|
265
265
|
|
266
|
-
IMAGE_FORMATS = %w(bmp png tif tiff jpg jpeg gif pdf ico eps)
|
266
|
+
IMAGE_FORMATS = %w(bmp png tif tiff jpg jpeg gif pdf ico eps jpc jp2 psd)
|
267
267
|
|
268
268
|
def self.supported_image_format?(format)
|
269
269
|
format = format.to_s.downcase
|
data/lib/cloudinary/version.rb
CHANGED
data/spec/utils_spec.rb
CHANGED
@@ -104,11 +104,15 @@ describe Cloudinary::Utils do
|
|
104
104
|
result.should == "http://res.cloudinary.com/test123/image/upload/c_crop,h_100,w_100/test"
|
105
105
|
end
|
106
106
|
|
107
|
-
it "should not pass width and height to html in case of fit or limit crop" do
|
107
|
+
it "should not pass width and height to html in case of fit, lfill or limit crop" do
|
108
108
|
options = {:width=>100, :height=>100, :crop=>:limit}
|
109
109
|
result = Cloudinary::Utils.cloudinary_url("test", options)
|
110
110
|
options.should == {}
|
111
111
|
result.should == "http://res.cloudinary.com/test123/image/upload/c_limit,h_100,w_100/test"
|
112
|
+
options = {:width=>100, :height=>100, :crop=>:lfill}
|
113
|
+
result = Cloudinary::Utils.cloudinary_url("test", options)
|
114
|
+
options.should == {}
|
115
|
+
result.should == "http://res.cloudinary.com/test123/image/upload/c_lfill,h_100,w_100/test"
|
112
116
|
options = {:width=>100, :height=>100, :crop=>:fit}
|
113
117
|
result = Cloudinary::Utils.cloudinary_url("test", options)
|
114
118
|
options.should == {}
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cloudinary
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.58
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-05-
|
14
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rest-client
|