Sha256: 9abad7dd0d8203309a71ae348c41bfa37c08dc820fc35ca680d23087ed54e496

Contents?: true

Size: 744 Bytes

Versions: 1

Compression:

Stored size: 744 Bytes

Contents

module LatoMedia
  class Media < ActiveRecord::Base

    IMAGES_SIZES = {
      large: "#{CONFIGS[:lato_media][:large_media_width]}x#{CONFIGS[:lato_media][:large_media_width]}>",
      medium: "#{CONFIGS[:lato_media][:medium_media_width]}x#{CONFIGS[:lato_media][:medium_media_width]}>",
      thumb: "#{CONFIGS[:lato_media][:thumb_media_width]}x#{CONFIGS[:lato_media][:thumb_media_width]}>"
    }

    # Dependencies:

    include Media::EntityHelpers

    # Other settings:

    has_attached_file :attachment, styles: lambda { |a| a.content_type =~ /^image/ ? IMAGES_SIZES : {} }
    do_not_validate_attachment_file_type :attachment

    # Callbacks:

    before_save do
      self.title = attachment_file_name unless title
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
lato_media-2.1 app/models/lato_media/media.rb