我可以通过 Omniauth 获取 Facebook 头像,但我只能调整默认图像的大小,而不是默认为 50 x 50px 的 Facebook 图像。如何将其调整为 38px?
这是我的应用程序助手:
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
和我的用户类:
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