Class: Avatar
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Avatar
- Defined in:
- app/models/polymorphic/avatar.rb
Overview
Copyright © 2008-2013 Michael Dvorkin and contributors.
Fat Free CRM is freely distributable under the terms of MIT license. See MIT-LICENSE file or www.opensource.org/licenses/mit-license.php
Schema Information
Table name: avatars
id :integer not null, primary key
user_id :integer
entity_id :integer
entity_type :string(255)
image_file_size :integer
image_file_name :string(255)
image_content_type :string(255)
created_at :datetime
updated_at :datetime
Constant Summary collapse
- STYLES =
{ large: "75x75#", medium: "50x50#", small: "25x25#", thumb: "16x16#" }.freeze
Class Method Summary collapse
-
.size_from_style!(options) ⇒ Object
Convert STYLE symbols to ‘w x h’ format for Gravatar and Rails e.g.
Class Method Details
.size_from_style!(options) ⇒ Object
Convert STYLE symbols to ‘w x h’ format for Gravatar and Rails e.g. Avatar.size_from_style(:size => :large) -> ‘75x75’ Allow options to contain :width and :height override keys
47 48 49 50 51 52 53 54 55 56 |
# File 'app/models/polymorphic/avatar.rb', line 47 def self.size_from_style!() if [:width] && [:height] [:size] = %i[width height].map { |d| [d] }.join("x") .delete(:width) .delete(:height) elsif Avatar::STYLES.keys.include?([:size]) [:size] = Avatar::STYLES[[:size]].sub(/\#\z/, '') end end |