Sha256: 31b6c3cd93705e488625d03c64b0dc9751f1b10473b66339a023652e546d25c9

Contents?: true

Size: 951 Bytes

Versions: 4

Compression:

Stored size: 951 Bytes

Contents

class SpudPhoto < ActiveRecord::Base

  attr_accessible :title, :caption, :photo

  has_many :spud_photo_albums_photos, :dependent => :destroy
  has_many :albums,
    :through => :spud_photo_albums_photos,
    :source => :spud_photo_album

  has_attached_file :photo, 
    :styles => lambda { |attachment| attachment.instance.dynamic_styles },
    :convert_options => Spud::Photos.config.convert_options,
    :storage => Spud::Photos.paperclip_storage,
    :s3_credentials => Spud::Photos.s3_credentials,
    :url => Spud::Photos.storage_url,
    :path => Spud::Photos.storage_path

  validates_attachment_presence :photo

  def dynamic_styles
    compress = '-strip -density 72x72'
    admin_styles = {
      :spud_admin_small => {:geometry => '125x125#', :convert_options => compress},
      :spud_admin_medium => {:geometry => '300x200', :convert_options => compress}
    }
    return admin_styles.merge(Spud::Photos.config.photo_styles)
  end

end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
tb_photos-1.0 app/models/spud_photo.rb
spud_photos-0.9.2 app/models/spud_photo.rb
spud_photos-0.9.1 app/models/spud_photo.rb
spud_photos-0.9.0.2 app/models/spud_photo.rb