Sha256: b2c688dbbd23d99549e2c0d1678c11a9a0eeb24cc3f86ee47bc4e9102f76eff9

Contents?: true

Size: 1.37 KB

Versions: 3

Compression:

Stored size: 1.37 KB

Contents

class Image < ActiveRecord::Base

	# Docs for attachment_fu http://github.com/technoweenie/attachment_fu
  has_attachment :content_type => :image,
                 :storage => (USE_S3_BACKEND ? :s3 : :file_system),
                 :path_prefix => (USE_S3_BACKEND ? nil : 'public/system/images'),
                 :processor => 'Rmagick',
                 :thumbnails => ((((thumbnails = RefinerySetting.find_or_set(:image_thumbnails, {})).is_a?(Hash) ? thumbnails : (RefinerySetting[:image_thumbnails] = {}))) rescue {}),
                 :max_size => 50.megabytes

 	validates_as_attachment

  # Docs for acts_as_indexed http://github.com/dougal/acts_as_indexed
  acts_as_indexed :fields => [:title],
          				:index_file => [Rails.root.to_s, "tmp", "index"]

	named_scope :thumbnails, :conditions => "parent_id NOT NULL"
	named_scope :originals, :conditions => {:parent_id => nil}

	# when a dialog pops up with images, how many images per page should there be
	PAGES_PER_DIALOG = 18

	# when listing images out in the admin area, how many images should show per page
	PAGES_PER_ADMIN_INDEX = 20

	# How many images per page should be displayed?
  def self.per_page(dialog = false)
    dialog ? PAGES_PER_DIALOG : PAGES_PER_ADMIN_INDEX
  end
  
  # Returns a titleized version of the filename
	# my_file.jpg returns My File
  def title
    self.filename.gsub(/\.\w+$/, '').titleize
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
refinerycms-0.9.6.5 vendor/plugins/images/app/models/image.rb
refinerycms-0.9.6.4 vendor/plugins/images/app/models/image.rb
refinerycms-0.9.6.3 vendor/plugins/images/app/models/image.rb