Module: Gluttonberg::Library::AttachmentMixin::ClassMethods

Defined in:
lib/gluttonberg/library/attachment_mixin.rb

Instance Method Summary collapse

Instance Method Details

#generate_nameObject

Generate auto titles for those assets without name



40
41
42
43
44
45
46
47
48
# File 'lib/gluttonberg/library/attachment_mixin.rb', line 40

def generate_name
  assets = Asset.find(:all , :conditions => { :name => "" } )
  assets.each do |asset|
    p asset.file_name
    asset.name = asset.file_name.split(".")[0]
    asset.save
  end
  'done' # this just makes the output nicer when running from slice -i
end

#max_image_sizeObject

Returns the max image size as a hash containing :width and :height. May be the default, or the value configured for a particular project.



63
64
65
# File 'lib/gluttonberg/library/attachment_mixin.rb', line 63

def max_image_size
  Rails.configuration.max_image_size || MAX_IMAGE_SIZE
end

#sizesObject

Returns a collection of thumbnail definitions — sizes, filename etc. — which is a merge of defaults and any custom thumbnails defined by the user.



53
54
55
56
57
58
59
# File 'lib/gluttonberg/library/attachment_mixin.rb', line 53

def sizes
  @thumbnail_sizes ||= if Rails.configuration.thumbnails
    Rails.configuration.thumbnails.merge(DEFAULT_THUMBNAILS)
  else
    DEFAULT_THUMBNAILS
  end
end