[refs #265] fixed user avatars

This commit is contained in:
Alexander Machehin 2012-03-11 23:06:41 +06:00
parent 6d5120e5cc
commit 6a7d9636f5
8 changed files with 13 additions and 8 deletions

View File

@ -1,7 +1,12 @@
# -*- encoding : utf-8 -*- # -*- encoding : utf-8 -*-
module UsersHelper module UsersHelper
def avatar_url_by_email(email, size = :small)
avatar_url(User.where(:email => email).first, size)
end
def avatar_url(user, size = :small) def avatar_url(user, size = :small)
if user.avatar? if user.try('avatar?')
user.avatar.url(size) user.avatar.url(size)
else else
gravatar_url(user.email, user.avatar.styles[size].geometry.split('x').first) gravatar_url(user.email, user.avatar.styles[size].geometry.split('x').first)

View File

@ -1,7 +1,7 @@
- if defined? user_email - if defined? user_email
.top .top
.image .image
= image_tag(gravatar_url(user_email, 30)) = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar')
.text .text
%span.name %span.name
= link_to user_name, user_path(user_id) = link_to user_name, user_path(user_id)

View File

@ -1,6 +1,6 @@
.top .top
.image .image
= image_tag(gravatar_url(activity_feed.user.email, 30)) = image_tag(avatar_url_by_email(activity_feed.user.email, :small), :alt => 'avatar')
.text .text
%span.name %span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname) = link_to activity_feed.user.uname, user_path(activity_feed.user.uname)

View File

@ -1,6 +1,6 @@
.top .top
.image .image
= image_tag(gravatar_url(user_email, 30)) = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar')
.text .text
%span.name %span.name
= link_to user_name, user_path(user_id) = link_to user_name, user_path(user_id)

View File

@ -1,6 +1,6 @@
.top .top
.image .image
= image_tag(gravatar_url(user_email, 30)) = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar')
.text .text
%span.name %span.name
= link_to user_name, user_path(user_id) = link_to user_name, user_path(user_id)

View File

@ -1,6 +1,6 @@
.top .top
.image .image
= image_tag(gravatar_url(user_email, 30)) = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar')
.text .text
%span.name %span.name
= link_to user_name, user_path(user_id) = link_to user_name, user_path(user_id)

View File

@ -1,6 +1,6 @@
.top .top
.image .image
= image_tag(gravatar_url(activity_feed.user.email, 30)) = image_tag(avatar_url_by_email(activity_feed.user.email, :small), :alt => 'avatar')
.text .text
%span.name %span.name
= link_to activity_feed.user.uname, user_path(activity_feed.user.uname) = link_to activity_feed.user.uname, user_path(activity_feed.user.uname)

View File

@ -1,6 +1,6 @@
.top .top
.image .image
= image_tag(gravatar_url(user_email, 30)) = image_tag(avatar_url_by_email(user_email, :small), :alt => 'avatar')
.text .text
%span.name %span.name
= link_to user_name, user_path(user_id) = link_to user_name, user_path(user_id)