paperclip_utils 1.2.1 → 1.2.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/paperclip_utils/version.rb +1 -1
- data/lib/paperclip_utils.rb +11 -13
- 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: edb0136a20bafc183e70c8be005f63d73e6ce48b
|
4
|
+
data.tar.gz: da33fd10aaeda193e7cdd14e73bd288b385ca8e0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e02327b9b03ed0818f04aca9142d4d8009384e854674a7ea093538941a55f8b626f993ba309458b30b297124344f6a2a08419360a69e0123c6f44bf5152e36de
|
7
|
+
data.tar.gz: d0d39cbecf6bd53b80a58e5c4cb67e039fa2e29ce984670ae919418611e8db823f89b8308d75390e1aa98bcf8cb9651544c68fef3dab83fbf79282e07e068c94
|
data/lib/paperclip_utils.rb
CHANGED
@@ -3,16 +3,14 @@ require 'paperclip_processors/ghostscript.rb'
|
|
3
3
|
|
4
4
|
module Paperclip
|
5
5
|
class Utils
|
6
|
-
def self.get_processors(content_type,
|
7
|
-
if
|
8
|
-
if
|
9
|
-
processors = to_processors
|
10
|
-
|
6
|
+
def self.get_processors(content_type, processors: [:thumbnail], fallback_processors: [], allowed_content_types: ALLOWED_CONTENT_TYPES)
|
7
|
+
if processors
|
8
|
+
if processors.is_a?(Array)
|
11
9
|
if processors.include?(:thumbnail) && content_type == 'application/pdf' && !processors.include?(:ghostscript)
|
12
10
|
processors.unshift(:ghostscript)
|
13
11
|
end
|
14
|
-
elsif
|
15
|
-
processors = [
|
12
|
+
elsif processors.is_a?(Symbol)
|
13
|
+
processors = [processors]
|
16
14
|
else
|
17
15
|
processors = []
|
18
16
|
end
|
@@ -31,17 +29,17 @@ module Paperclip
|
|
31
29
|
return (allowed_content_types.include?(content_type) ? processors : fallback_processors)
|
32
30
|
end
|
33
31
|
|
34
|
-
def self.get_styles(content_type,
|
35
|
-
if
|
32
|
+
def self.get_styles(content_type, styles: {preview: "800x600>", thumb: "100x100>"}, fallback_styles: {}, allowed_content_types: ALLOWED_CONTENT_TYPES)
|
33
|
+
if styles
|
36
34
|
if ['application/pdf','image/tiff','image/tif','image/x-tiff'].include?(content_type)
|
37
|
-
|
38
|
-
|
35
|
+
styles.each do |k,v|
|
36
|
+
styles[k] = [(v.is_a?(String) ? v : v[0]), :jpg]
|
39
37
|
end
|
40
38
|
end
|
41
39
|
else
|
42
|
-
|
40
|
+
styles = []
|
43
41
|
end
|
44
|
-
return (allowed_content_types.include?(content_type) ?
|
42
|
+
return (allowed_content_types.include?(content_type) ? styles : fallback_styles)
|
45
43
|
end
|
46
44
|
|
47
45
|
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']
|