cloudinary 1.0.24 → 1.0.25

Sign up to get free protection for your applications and to get access to all the features.
@@ -40,14 +40,17 @@ class Cloudinary::CarrierWave::Storage < ::CarrierWave::Storage::Abstract
40
40
  def store_cloudinary_version(version)
41
41
  name = "v#{version}/#{identifier.split("/").last}"
42
42
  model_class = uploader.model.class
43
+ column = uploader.model.send(:_mounter, uploader.mounted_as).send(:serialization_column)
43
44
  if defined?(ActiveRecord::Base) && uploader.model.is_a?(ActiveRecord::Base)
44
45
  primary_key = model_class.primary_key.to_sym
45
- model_class.update_all({uploader.mounted_as=>name}, {primary_key=>uploader.model.send(primary_key)})
46
- uploader.model.send :write_attribute, uploader.mounted_as, name
47
- elsif model_class.respond_to?(:update_all) && uploader.model.respond_to?(:_id)
46
+ model_class.update_all({column=>name}, {primary_key=>uploader.model.send(primary_key)})
47
+ uploader.model.send :write_attribute, column, name
48
+ elsif defined?(Mongoid::Document) && uploader.model.is_a?(Mongoid::Document)
48
49
  # Mongoid support
49
- model_class.where(:_id=>uploader.model._id).update_all(uploader.mounted_as=>name)
50
- uploader.model.send :write_attribute, uploader.mounted_as, name
50
+ uploader.model.set(column, name)
51
+ elsif model_class.respond_to?(:update_all) && uploader.model.respond_to?(:_id)
52
+ model_class.where(:_id=>uploader.model._id).update_all(column=>name)
53
+ uploader.model.send :write_attribute, column, name
51
54
  else
52
55
  raise "Only ActiveRecord and Mongoid are supported at the moment!"
53
56
  end
@@ -61,7 +61,7 @@ class Cloudinary::Uploader
61
61
  {
62
62
  :timestamp=>Time.now.to_i,
63
63
  :tag=>tag,
64
- :transformation => Cloudinary::Utils.generate_transformation_string(options)
64
+ :transformation => Cloudinary::Utils.generate_transformation_string(options.merge(:fetch_format=>options[:format]))
65
65
  }
66
66
  end
67
67
 
@@ -11,11 +11,13 @@ class Cloudinary::Utils
11
11
  options[:width], options[:height] = size.split("x") if size
12
12
  width = options[:width]
13
13
  height = options[:height]
14
- options.delete(:width) if width && width.to_f < 1
15
- options.delete(:height) if height && height.to_f < 1
14
+ has_overlay = !options[:overlay].blank?
15
+
16
+ options.delete(:width) if width && (width.to_f < 1 || has_overlay)
17
+ options.delete(:height) if height && (height.to_f < 1 || has_overlay)
16
18
 
17
19
  crop = options.delete(:crop)
18
- width=height=nil if crop.nil?
20
+ width=height=nil if crop.nil? && !has_overlay
19
21
 
20
22
  background = options.delete(:background)
21
23
  background = background.sub(/^#/, 'rgb:') if background
@@ -1,4 +1,4 @@
1
1
  # Copyright Cloudinary
2
2
  module Cloudinary
3
- VERSION = "1.0.24"
3
+ VERSION = "1.0.25"
4
4
  end
data/spec/utils_spec.rb CHANGED
@@ -226,5 +226,12 @@ describe Cloudinary::Utils do
226
226
  options.should == {}
227
227
  result.should == "http://res.cloudinary.com/test123/image/upload/e_sepia:10/test"
228
228
  end
229
+
230
+ it "should not pass width/height to html for overlay" do
231
+ options = {:overlay=>"text:hello", :height=>100, :width=>100}
232
+ result = Cloudinary::Utils.cloudinary_url("test", options)
233
+ options.should == {}
234
+ result.should == "http://res.cloudinary.com/test123/image/upload/h_100,l_text:hello,w_100/test"
235
+ end
229
236
 
230
237
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: cloudinary
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 1.0.24
5
+ version: 1.0.25
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nadav Soferman
@@ -12,7 +12,7 @@ autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
14
 
15
- date: 2012-05-17 00:00:00 +03:00
15
+ date: 2012-06-05 00:00:00 +03:00
16
16
  default_executable:
17
17
  dependencies:
18
18
  - !ruby/object:Gem::Dependency