Class: PhotoUploader
- Inherits:
-
ApplicationUploader
- Object
- CarrierWave::Uploader::Base
- ApplicationUploader
- PhotoUploader
- Includes:
- ImageDefaults
- Defined in:
- app/uploaders/photo_uploader.rb
Instance Attribute Summary collapse
-
#height ⇒ Object
readonly
Returns the value of attribute height.
-
#width ⇒ Object
readonly
Returns the value of attribute width.
Instance Method Summary collapse
Methods included from ImageDefaults
Methods inherited from ApplicationUploader
Instance Attribute Details
#height ⇒ Object (readonly)
Returns the value of attribute height.
24 25 26 |
# File 'app/uploaders/photo_uploader.rb', line 24 def height @height end |
#width ⇒ Object (readonly)
Returns the value of attribute width.
24 25 26 |
# File 'app/uploaders/photo_uploader.rb', line 24 def width @width end |
Instance Method Details
#capture_size(file) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/uploaders/photo_uploader.rb', line 28 def capture_size(file) if version_name.blank? if file.path.nil? img = ::MiniMagick::Image::read(file.file) @width = img[:width] @height = img[:height] else @width, @height = `identify -format "%wx %h" #{file.path}`.split(/x/).map{|dim| dim.to_i } end end end |
#default_url ⇒ Object
4 5 6 |
# File 'app/uploaders/photo_uploader.rb', line 4 def default_url ActionController::Base.helpers.asset_path("images/default_photo.png") end |
#url ⇒ Object
8 9 10 11 12 13 14 |
# File 'app/uploaders/photo_uploader.rb', line 8 def url if File.exist? file.file file.file.match(/\/system\/uploads\/.*/).to_s else "/assets/tramway/core/mona_lisa_from_prado_square.jpg" end end |