carrierwave-crop 0.1.1 → 0.1.2
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 +4 -4
- data/CHANGELOG.md +8 -1
- data/README.md +32 -25
- data/carrierwave-crop.gemspec +1 -1
- data/lib/carrierwave/crop/helpers.rb +4 -3
- data/lib/carrierwave/crop/model_additions.rb +1 -1
- data/lib/carrierwave/crop/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: eade0956164d50cc9e0a5468d2735279816c1a36
|
4
|
+
data.tar.gz: fbdd13505721e2269b36a706322f8214c2f3897d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7592c42b07bb74fb05888c062fb71462f139060d19d973b97f2392cb0524e07763da86bdc0321588f5756b939383918994e4862032c7336b2187523d02264ca2
|
7
|
+
data.tar.gz: 821961cf39d8b962cddfb6c9e391acd59a259852881eb6ac88ec7f28516b649723025d4286398c2e0283ba31c3b7f689ae8d8ceeef96b54ecb33c5e1ca879e85
|
data/CHANGELOG.md
CHANGED
@@ -10,9 +10,11 @@
|
|
10
10
|
* Supports cropping of ONE attachment per model. Can be directly applied on original attachment if no versions exists.
|
11
11
|
|
12
12
|
process crop: :avatar
|
13
|
+
|
13
14
|
* Supports cropping of MULTIPLE versions of one attachment per model.
|
14
15
|
* Updated the cropping coffeescript (created by rails generator) to incorporate the changes in form helpers.
|
15
16
|
* Added `version`, `width` and `height` options to form helpers `cropbox` and `previewbox`.
|
17
|
+
|
16
18
|
##To render a specific version for cropping pass `version` option.
|
17
19
|
<%= f.cropbox :avatar , version: :medium %>
|
18
20
|
<%= f.peviewbox :avatar , version: :medium %> ## Pass the same version as specified in cropbox
|
@@ -20,7 +22,9 @@
|
|
20
22
|
## If you override ONE of width/height you MUST override both, otherwise passed option would be ignored.
|
21
23
|
<%= f.cropbox :avatar, width: 550, height: 600 %>
|
22
24
|
<%= f.previewbox :avatar, width: 200, height: 200 %>
|
25
|
+
|
23
26
|
* Added `width` and `height` arguments to proccessor method `crop`.
|
27
|
+
|
24
28
|
## If ONLY "thumb" version is to be cropped
|
25
29
|
version :jumbo do
|
26
30
|
resize_to_limit(600,600)
|
@@ -40,4 +44,7 @@
|
|
40
44
|
## Specify both width and height values otherwise they would be ignored
|
41
45
|
process crop: [:avatar, 600, 600]
|
42
46
|
resize_to_limit(100,100)
|
43
|
-
end
|
47
|
+
end
|
48
|
+
|
49
|
+
## CarrierWave-Crop v0.1.1
|
50
|
+
* Fixes Issue #1: Colons in html `id` attribute for Namespaced Models
|
data/README.md
CHANGED
@@ -113,53 +113,60 @@ If there are no versions, and original file is to be cropped directly then call
|
|
113
113
|
|
114
114
|
**To use `rmagick`, add it in your `Gemfile` as:**
|
115
115
|
|
116
|
-
|
116
|
+
gem 'rmagick', :require => 'RMagick' ## Specify appropriate version, if needed
|
117
117
|
|
118
118
|
Run `bundle`
|
119
119
|
|
120
120
|
Include it in your CarrierWave Uploader. For example:
|
121
121
|
|
122
|
-
|
123
|
-
|
122
|
+
class AvatarUploader < CarrierWave::Uploader::Base
|
123
|
+
include CarrierWave::RMagick
|
124
124
|
...
|
125
|
-
|
125
|
+
end
|
126
126
|
|
127
127
|
**To use `mini_magick`, add it in your `Gemfile` as:**
|
128
128
|
|
129
|
-
|
129
|
+
gem 'mini_magick' ## Specify appropriate version, if needed
|
130
130
|
|
131
131
|
Run `bundle`
|
132
132
|
|
133
133
|
Include it in your CarrierWave Uploader. For example:
|
134
134
|
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
135
|
+
class AvatarUploader < CarrierWave::Uploader::Base
|
136
|
+
include CarrierWave::MiniMagick
|
137
|
+
...
|
138
|
+
end
|
139
139
|
|
140
140
|
3. Supports cropping of ONE attachment per model. Can be directly applied on original attachment if no versions exists.
|
141
|
-
|
141
|
+
|
142
|
+
process crop: :avatar
|
143
|
+
|
142
144
|
4. Supports cropping of MULTIPLE versions of one attachment per model.
|
143
145
|
5. In form helpers, by default *original image* is rendered. To render a specific version for cropping pass `version` option. For example:
|
144
|
-
|
145
|
-
|
146
|
+
|
147
|
+
<%= f.cropbox :avatar , version: :medium %>
|
148
|
+
<%= f.peviewbox :avatar , version: :medium %> ## Pass the same version as specified in cropbox
|
149
|
+
|
146
150
|
6. By default `previewbox` has `100x100` dimensions and `cropbox` defaults to the target geometry for the version.
|
147
151
|
`width` and `height` can be specified for these form helpers. BUT If you override ONE of width/height you MUST override both, otherwise passed option would be ignored.
|
148
|
-
|
149
|
-
|
152
|
+
|
153
|
+
<%= f.cropbox :avatar, width: 550, height: 600 %>
|
154
|
+
<%= f.previewbox :avatar, width: 200, height: 200 %>
|
155
|
+
|
150
156
|
7. By default, `process crop: :avatar` will create the cropped version based on original image.
|
151
157
|
To resize the image to a particular dimension before cropping, pass two more arguments `width` and `height`.
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
158
|
+
|
159
|
+
## If ONLY "thumb" version is to be cropped
|
160
|
+
version :jumbo do
|
161
|
+
resize_to_limit(600,600)
|
162
|
+
end
|
163
|
+
|
164
|
+
version :thumb do
|
165
|
+
## To crop this version based on `jumbo` version, pass width = 600 and height = 600
|
166
|
+
## Specify both width and height values otherwise they would be ignored
|
167
|
+
process crop: [:avatar, 600, 600]
|
168
|
+
resize_to_limit(100,100)
|
169
|
+
end
|
163
170
|
|
164
171
|
### Credits and resources
|
165
172
|
* [CarrierWave](https://github.com/carrierwaveuploader/carrierwave)
|
data/carrierwave-crop.gemspec
CHANGED
@@ -6,7 +6,7 @@ require 'carrierwave/crop/version'
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
7
|
spec.name = "carrierwave-crop"
|
8
8
|
spec.version = CarrierWave::Crop::VERSION
|
9
|
-
spec.authors = ["
|
9
|
+
spec.authors = ["Kirti Thorat"]
|
10
10
|
spec.email = ["kirti.brenz@gmail.com"]
|
11
11
|
spec.summary = %q{CarrierWave extension for cropping images with preview.}
|
12
12
|
spec.description = %q{CarrierWave extension to crop uploaded images using Jcrop plugin.}
|
@@ -20,7 +20,8 @@ module CarrierWave
|
|
20
20
|
attachment = attachment.to_sym
|
21
21
|
|
22
22
|
if(self.object.send(attachment).class.ancestors.include? CarrierWave::Uploader::Base )
|
23
|
-
|
23
|
+
## Fixes Issue #1 : Colons in html id attributes with Namespaced Models
|
24
|
+
model_name = self.object.class.name.downcase.split("::").last
|
24
25
|
width, height = 100, 100
|
25
26
|
if(opts[:width] && opts[:height])
|
26
27
|
width, height = opts[:width].round, opts[:height].round
|
@@ -52,8 +53,8 @@ module CarrierWave
|
|
52
53
|
attachment_instance = self.object.send(attachment)
|
53
54
|
|
54
55
|
if(attachment_instance.class.ancestors.include? CarrierWave::Uploader::Base )
|
55
|
-
|
56
|
-
model_name = self.object.class.name.downcase
|
56
|
+
## Fixes Issue #1 : Colons in html id attributes with Namespaced Models
|
57
|
+
model_name = self.object.class.name.downcase.split("::").last
|
57
58
|
hidden_elements = self.hidden_field(:"#{attachment}_crop_x", id: "#{model_name}_#{attachment}_crop_x")
|
58
59
|
[:crop_y, :crop_w, :crop_h].each do |attribute|
|
59
60
|
hidden_elements << self.hidden_field(:"#{attachment}_#{attribute}", id: "#{model_name}_#{attachment}_#{attribute}")
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: carrierwave-crop
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
|
-
-
|
7
|
+
- Kirti Thorat
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|