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.



41
42
43
# File 'app/uploaders/photo_uploader.rb', line 41

def height
  @height
end

#widthObject (readonly)

Returns the value of attribute width.



41
42
43
# File 'app/uploaders/photo_uploader.rb', line 41

def width
  @width
end

Instance Method Details

#capture_size(file) ⇒ Object



45
46
47
48
49
50
51
52
53
54
55
# File 'app/uploaders/photo_uploader.rb', line 45

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(&:to_i)
    end
  end
end

#default_urlObject



6
7
8
# File 'app/uploaders/photo_uploader.rb', line 6

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

#urlObject



10
11
12
13
14
15
16
# File 'app/uploaders/photo_uploader.rb', line 10

def url
  if file.present? && File.exist?(file.file)
    file.file.match(%r{/system/uploads/.*}).to_s
  else
    '/assets/tramway/core/mona_lisa_from_prado_square.jpg'
  end
end