diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 69869f7..f294671 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -1,6 +1,15 @@ module ApplicationHelper MAX_PAGES = 15 + def avatar_img(user, size) + image_tag(user.avatar_url(size), { + :srcset => "#{user.avatar_url(size)} 1x, " << + "#{user.avatar_url(size * 2)} 2x", + :class => "avatar", + :size => "#{size}x#{size}", + :alt => "#{user.username} avatar" }) + end + def break_long_words(str, len = 30) safe_join(str.split(" ").map{|w| if w.length > len diff --git a/app/views/comments/_comment.html.erb b/app/views/comments/_comment.html.erb index c4be4ce..51d3337 100644 --- a/app/views/comments/_comment.html.erb +++ b/app/views/comments/_comment.html.erb @@ -38,8 +38,8 @@ class="comment <%= comment.current_vote ? (comment.current_vote[:vote] == 1 ? <% end %> <% if (@user && @user.show_avatars?) || !@user %> - + <%= + avatar_img(comment.user, 16) %> <% end %> <% end %> <% if (@user && @user.show_avatars?) || !@user %> - + <%= + avatar_img(ms.user, 16) %> <% end %> <% if story.user_is_author? %> <%= t('.authoredby') %> @@ -92,10 +90,8 @@ class="story <%= story.vote && story.vote[:vote] == 1 ? "upvoted" : "" %>
<% if (@user && @user.show_avatars?) || !@user %> - + <%= + avatar_img(story.user, 16) %> <% end %> <% if story.previewing %> <% if story.user_is_author? %> diff --git a/app/views/users/show.html.erb b/app/views/users/show.html.erb index 10ca8ee..f9ee06a 100644 --- a/app/views/users/show.html.erb +++ b/app/views/users/show.html.erb @@ -17,9 +17,7 @@ <% if @showing_user.is_active? %>
- + <%= avatar_img(@showing_user, 100) %>
<% end %>