Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 87 lines (76 sloc) 1.744 kb
2d4983f @fredwu Added portraits importing and resizing so that portraits are served loca...
authored
1 class PortraitUploader < CarrierWave::Uploader::Base
2
3 ##
4 # Image manipulator library:
5 #
6 # include CarrierWave::RMagick
7 # include CarrierWave::ImageScience
8 include CarrierWave::MiniMagick
9
10 ##
11 # Storage type
12 #
13 storage :file
14 #
15 # configure do |config|
16 # config.s3_access_key_id = 'xxxx'
17 # config.s3_secret_access_key = 'xxxx'
18 # config.s3_bucket = 'assets-web'
19 # end
20 #
21 # storage :right_s3
22
23
24 ## Manually set root
25 def root; File.join(Padrino.root,"public/"); end
26
27 ##
28 # Directory where uploaded files will be stored (default is /public/uploads)
29 #
30 def store_dir
31 'images/portraits/'
32 end
33
34 ##
35 # Directory where uploaded temp files will be stored (default is [root]/tmp)
36 #
37 def cache_dir
38 Padrino.root("tmp")
39 end
40
41 ##
42 # Default URL as a default if there hasn't been a file uploaded
43 #
44 def default_url
ecc0630 @fredwu Style it up baby!
authored
45 'portrait.jpg'
2d4983f @fredwu Added portraits importing and resizing so that portraits are served loca...
authored
46 end
47
48 ##
49 # Process files as they are uploaded.
50 #
d3f004a @fredwu Okay, fixed 100x100px sized portraits work heaps better with the deisng,...
authored
51 process :resize_to_fill => [100, 100]
2d4983f @fredwu Added portraits importing and resizing so that portraits are served loca...
authored
52 # version :thumb do
53 # process :resize_to_fill => [100, 100]
54 # end
55 #
56 # def scale(width, height)
57 # # do something
58 # end
59
60 ##
61 # Create different versions of your uploaded files
62 #
63 # version :header do
64 # process :resize_to_fill => [940, 250]
65 # version :thumb do
66 # process :resize_to_fill => [230, 85]
67 # end
68 # end
69 ##
70 # White list of extensions which are allowed to be uploaded:
71 #
72 # def extension_white_list
73 # %w(jpg jpeg gif png)
74 # end
75
76 ##
77 # Override the filename of the uploaded files
78 #
79 def filename
80 if original_filename
81 original_extname = File.extname(original_filename)
82 "#{model.hero.username}_#{model.id}#{original_extname.blank? ? '.jpg' : original_extname}"
83 end
84 end
85 #
86 end
Something went wrong with that request. Please try again.