Class: PhotoUploader

Inherits:
ApplicationUploader show all
Includes:
ImageDefaults
Defined in:
app/uploaders/photo_uploader.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from ImageDefaults

#extension_white_list

Methods inherited from ApplicationUploader

#store_dir

Instance Attribute Details

#heightObject (readonly)

Returns the value of attribute height.



24
25
26
# File 'app/uploaders/photo_uploader.rb', line 24

def height
  @height
end

#widthObject (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_urlObject



4
5
6
# File 'app/uploaders/photo_uploader.rb', line 4

def default_url
  ActionController::Base.helpers.asset_path("images/default_photo.png")
end

#urlObject



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