Sha256: cd0a56b587b7c9f50fe619d6297b0d9d543b46e3204763cc67b23d2717821c9c

Contents?: true

Size: 757 Bytes

Versions: 62

Compression:

Stored size: 757 Bytes

Contents

module Workarea
  class User
    module Avatar
      extend ActiveSupport::Concern

      included do
        extend Dragonfly::Model

        field :avatar_name, type: String
        field :avatar_uid, type: String

        dragonfly_accessor :avatar, app: :workarea
      end

      def avatar_image_url
        if avatar.present?
          avatar.process(:avatar).url
        elsif !Rails.env.test?
          gravatar_url
        else
          'workarea/core/placeholder.png'
        end
      end

      def gravatar_url(options = {})
        options = Workarea.config.gravatar_options.merge(options)
        hash = Digest::MD5.hexdigest(email.downcase)
        "https://www.gravatar.com/avatar/#{hash}?#{options.to_query}"
      end
    end
  end
end

Version data entries

62 entries across 62 versions & 1 rubygems

Version Path
workarea-core-3.5.27 app/models/workarea/user/avatar.rb
workarea-core-3.5.26 app/models/workarea/user/avatar.rb
workarea-core-3.4.45 app/models/workarea/user/avatar.rb
workarea-core-3.5.25 app/models/workarea/user/avatar.rb
workarea-core-3.5.23 app/models/workarea/user/avatar.rb
workarea-core-3.4.44 app/models/workarea/user/avatar.rb
workarea-core-3.5.22 app/models/workarea/user/avatar.rb
workarea-core-3.4.43 app/models/workarea/user/avatar.rb
workarea-core-3.5.21 app/models/workarea/user/avatar.rb
workarea-core-3.4.42 app/models/workarea/user/avatar.rb
workarea-core-3.5.20 app/models/workarea/user/avatar.rb
workarea-core-3.4.41 app/models/workarea/user/avatar.rb
workarea-core-3.5.19 app/models/workarea/user/avatar.rb
workarea-core-3.4.40 app/models/workarea/user/avatar.rb
workarea-core-3.5.18 app/models/workarea/user/avatar.rb
workarea-core-3.4.39 app/models/workarea/user/avatar.rb
workarea-core-3.5.17 app/models/workarea/user/avatar.rb
workarea-core-3.4.38 app/models/workarea/user/avatar.rb
workarea-core-3.5.16 app/models/workarea/user/avatar.rb
workarea-core-3.4.37 app/models/workarea/user/avatar.rb