Sha256: 0e93cac9fda8e2b4c6596cfce30f2f30f3a6e9dc107766e66b5232bb19b080d3

Contents?: true

Size: 1.1 KB

Versions: 37

Compression:

Stored size: 1.1 KB

Contents

class PhotoUploader < ApplicationUploader
  include ImageDefaults

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

  def url
    if file.present? && File.exist?(file.file)
      file.file.match(/\/system\/uploads\/.*/).to_s
    else
      "/assets/tramway/core/mona_lisa_from_prado_square.jpg"
    end
  end

  version :medium do
    process :resize_to_fill => [400, 400]
  end

  version :small do
    process :resize_to_fill => [100, 100]
  end

  # FIXME move to tramway-landing uploader
  version :card do
    process resize_to_fill: [400, 400, 'North']
  end

  # FIXME move to tramway-landing uploader
  version :horizontal do
    process resize_to_fill: [800, 350, 'North']
  end

  attr_reader :width, :height

  before :cache, :capture_size

  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
end

Version data entries

37 entries across 37 versions & 1 rubygems

Version Path
tramway-core-1.8 app/uploaders/photo_uploader.rb
tramway-core-1.7.4 app/uploaders/photo_uploader.rb
tramway-core-1.7.3 app/uploaders/photo_uploader.rb
tramway-core-1.7.2 app/uploaders/photo_uploader.rb
tramway-core-1.7.1 app/uploaders/photo_uploader.rb
tramway-core-1.7 app/uploaders/photo_uploader.rb
tramway-core-1.6.4 app/uploaders/photo_uploader.rb
tramway-core-1.6.3 app/uploaders/photo_uploader.rb
tramway-core-1.6.2 app/uploaders/photo_uploader.rb
tramway-core-1.6.1 app/uploaders/photo_uploader.rb
tramway-core-1.6 app/uploaders/photo_uploader.rb
tramway-core-1.5.5.2 app/uploaders/photo_uploader.rb
tramway-core-1.5.5.1 app/uploaders/photo_uploader.rb
tramway-core-1.5.5 app/uploaders/photo_uploader.rb
tramway-core-1.5.4 app/uploaders/photo_uploader.rb
tramway-core-1.5.3 app/uploaders/photo_uploader.rb
tramway-core-1.5.2 app/uploaders/photo_uploader.rb
tramway-core-1.5.1 app/uploaders/photo_uploader.rb
tramway-core-1.5 app/uploaders/photo_uploader.rb
tramway-core-1.4.1 app/uploaders/photo_uploader.rb