2

I'm able to get the Facebook avatar through Omniauth, but I'm only able to resize the default image not the Facebook image which is 50 x 50px by default. How can I resize it to 38px?

Here's my application helper:

module ApplicationHelper
    def avatar_url(current_user)
        if current_user.avatar.present?
            current_user.avatar
        else
            gravatar_id = Digest::MD5.hexdigest(current_user.email.downcase)
            "http://gravatar.com/avatar/#{gravatar_id}.png?s=28&d=mm"
        end
    end
end

and my User class:

class User < ActiveRecord::Base
    def self.from_omniauth(auth)
        where(auth.slice(:sprovider, :uid)).first_or_create do |user|
            user.sprovider = auth.provider
            user.uid = auth.uid
            user.first_name = auth.info.first_name
            user.last_name = auth.info.last_name
            user.email = auth.info.email
            user.cell_phone = auth.info.cell_phone
            user.avatar = auth.info.image
        end
    end
Bayardo
  • 51
  • 2

0 Answers0