paperclip_utils 1.0.2 → 1.0.3
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/README.md +6 -6
- data/lib/paperclip_utils.rb +1 -1
- data/lib/paperclip_utils/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 1cf6204f5d5f6e63fa6e25a1c4216d12945b4c42
|
4
|
+
data.tar.gz: 70e73994cdd3ee3b3b5631a73987957ba9e4f770
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 74265b0ff12d98695471689d3502068e235b8c98ae18abd2b19fde49f1eb4d9ba170d9bd3bfebe991ef378f55abed002710981a95ff1ba8868912cce57b25e31
|
7
|
+
data.tar.gz: c007e4602f38a7d2d2a06c25dbcd059c4e07bf08adec24ddc31fa469732b20c84143cb2d26f110c4b22306f1d9dc6270cf7b804d5644624ead81e40e3a87982f
|
data/README.md
CHANGED
@@ -21,9 +21,9 @@ Paperclip::Utils.get_styles(content_type, styles_if_allowed, fallback_processors
|
|
21
21
|
# Usage
|
22
22
|
```ruby
|
23
23
|
class Post < ActiveRecord::Base
|
24
|
-
has_attachment :
|
25
|
-
styles: lambda{|x| Paperclip::Utils.get_styles(x.instance.
|
26
|
-
processors: lambda{|x| Paperclip::Utils.get_processors(x.
|
24
|
+
has_attachment :my_attachment,
|
25
|
+
styles: lambda{|x| Paperclip::Utils.get_styles(x.instance.my_attachment.content_type) },
|
26
|
+
processors: lambda{|x| Paperclip::Utils.get_processors(x.my_attachment.content_type) },
|
27
27
|
path: "public/system/:class/:attachment/:id_partition/:style/:filename",
|
28
28
|
url: "#{ActionController::Base.relative_url_root}/system/:class/:attachment/:id_partition/:style/:filename"
|
29
29
|
end
|
@@ -33,11 +33,11 @@ end
|
|
33
33
|
|
34
34
|
# Methods
|
35
35
|
|
36
|
-
**get_processors** - `Array(optional - default=[:ghostscript,:thumbnail]), Array(optional - default=[]), Array(optional - allowed content types)`
|
36
|
+
**get_processors** - `String(file content_type), Array(optional - default=[:ghostscript,:thumbnail]), Array(optional - default=[]), Array(optional - allowed content types)`
|
37
37
|
|
38
|
-
**get_styles** - `Hash(optional - default={preview: "800x600>", thumb: "100x100>"}), Hash(optional - default={}), Array(optional - allowed content types)`
|
38
|
+
**get_styles** - `String(file content type)Hash(optional - default={preview: "800x600>", thumb: "100x100>"}), Hash(optional - default={}), Array(optional - allowed content types)`
|
39
39
|
|
40
|
-
**
|
40
|
+
**ALLOWED_CONTENT_TYPES** - Default allowed content types. `['application/pdf', 'image/png', 'image/x-png', 'image/gif', 'image/jpeg', 'image/pjpeg', 'image/jpg', 'image/tif, ''image/tiff', 'image/x-tiff']`
|
41
41
|
|
42
42
|
|
43
43
|
|
data/lib/paperclip_utils.rb
CHANGED
@@ -17,7 +17,7 @@ module Paperclip
|
|
17
17
|
return (allowed_content_types.include?(content_type) ? processors : fallback_processors)
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.get_styles(content_type, to_styles
|
20
|
+
def self.get_styles(content_type, to_styles=nil, fallback_styles={}, allowed_content_types=ALLOWED_CONTENT_TYPES)
|
21
21
|
unless to_styles
|
22
22
|
if ['application/pdf','image/tiff','image/tif','image/x-tiff'].include?(content_type)
|
23
23
|
to_styles = {preview: ["800x600>", :png], thumb: ["100x100>", :png]}
|